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:
parent
297e11980b
commit
78db6bcf33
3 changed files with 16 additions and 3 deletions
|
@ -309,7 +309,7 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
|
||||||
{
|
{
|
||||||
http_data_t data = file->data;
|
http_data_t data = file->data;
|
||||||
grub_uint8_t *ptr;
|
grub_uint8_t *ptr;
|
||||||
int i;
|
int i, port;
|
||||||
struct grub_net_buff *nb;
|
struct grub_net_buff *nb;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
|
||||||
|
@ -391,8 +391,12 @@ http_establish (struct grub_file *file, grub_off_t offset, int initial)
|
||||||
grub_netbuff_put (nb, 2);
|
grub_netbuff_put (nb, 2);
|
||||||
grub_memcpy (ptr, "\r\n", 2);
|
grub_memcpy (ptr, "\r\n", 2);
|
||||||
|
|
||||||
|
if (file->device->net->port)
|
||||||
|
port = file->device->net->port;
|
||||||
|
else
|
||||||
|
port = HTTP_PORT;
|
||||||
data->sock = grub_net_tcp_open (file->device->net->server,
|
data->sock = grub_net_tcp_open (file->device->net->server,
|
||||||
HTTP_PORT, http_receive,
|
port, http_receive,
|
||||||
http_err, http_err,
|
http_err, http_err,
|
||||||
file);
|
file);
|
||||||
if (!data->sock)
|
if (!data->sock)
|
||||||
|
|
|
@ -1273,7 +1273,7 @@ grub_net_open_real (const char *name)
|
||||||
grub_net_app_level_t proto;
|
grub_net_app_level_t proto;
|
||||||
const char *protname, *server;
|
const char *protname, *server;
|
||||||
grub_size_t protnamelen;
|
grub_size_t protnamelen;
|
||||||
int try;
|
int try, port = 0;
|
||||||
|
|
||||||
if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0)
|
if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0)
|
||||||
{
|
{
|
||||||
|
@ -1290,7 +1290,14 @@ grub_net_open_real (const char *name)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *comma;
|
const char *comma;
|
||||||
|
char *colon;
|
||||||
comma = grub_strchr (name, ',');
|
comma = grub_strchr (name, ',');
|
||||||
|
colon = grub_strchr (name, ':');
|
||||||
|
if (colon)
|
||||||
|
{
|
||||||
|
port = (int) grub_strtol(colon+1, NULL, 10);
|
||||||
|
*colon = '\0';
|
||||||
|
}
|
||||||
if (comma)
|
if (comma)
|
||||||
{
|
{
|
||||||
protnamelen = comma - name;
|
protnamelen = comma - name;
|
||||||
|
@ -1325,6 +1332,7 @@ grub_net_open_real (const char *name)
|
||||||
if (server)
|
if (server)
|
||||||
{
|
{
|
||||||
ret->server = grub_strdup (server);
|
ret->server = grub_strdup (server);
|
||||||
|
ret->port = port;
|
||||||
if (!ret->server)
|
if (!ret->server)
|
||||||
{
|
{
|
||||||
grub_free (ret);
|
grub_free (ret);
|
||||||
|
|
|
@ -264,6 +264,7 @@ typedef struct grub_net
|
||||||
grub_fs_t fs;
|
grub_fs_t fs;
|
||||||
int eof;
|
int eof;
|
||||||
int stall;
|
int stall;
|
||||||
|
int port;
|
||||||
} *grub_net_t;
|
} *grub_net_t;
|
||||||
|
|
||||||
extern grub_net_t (*EXPORT_VAR (grub_net_open)) (const char *name);
|
extern grub_net_t (*EXPORT_VAR (grub_net_open)) (const char *name);
|
||||||
|
|
Loading…
Reference in a new issue