Allow non-default ports for HTTP requests

Add support for passing ports in HTTP requests. This takes the form of:
(http,serverip:portnum)/file
This commit is contained in:
Matthew Garrett 2016-01-07 17:27:15 -08:00
parent 297e11980b
commit 78db6bcf33
3 changed files with 16 additions and 3 deletions

View file

@ -1273,7 +1273,7 @@ grub_net_open_real (const char *name)
grub_net_app_level_t proto;
const char *protname, *server;
grub_size_t protnamelen;
int try;
int try, port = 0;
if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0)
{
@ -1290,7 +1290,14 @@ grub_net_open_real (const char *name)
else
{
const char *comma;
char *colon;
comma = grub_strchr (name, ',');
colon = grub_strchr (name, ':');
if (colon)
{
port = (int) grub_strtol(colon+1, NULL, 10);
*colon = '\0';
}
if (comma)
{
protnamelen = comma - name;
@ -1325,6 +1332,7 @@ grub_net_open_real (const char *name)
if (server)
{
ret->server = grub_strdup (server);
ret->port = port;
if (!ret->server)
{
grub_free (ret);