mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Explicitly document all cases when generating the Host header.
This commit is contained in:
parent
e38c88e458
commit
5b26cb40a9
@ -1,3 +1,8 @@
|
|||||||
|
2005-06-30 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* http.c (gethttp): Explicitly document the different cases when
|
||||||
|
generating the Host header.
|
||||||
|
|
||||||
2005-06-30 Hrvoje Niksic <hniksic@xemacs.org>
|
2005-06-30 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* host.c (pretty_print_address): Handle error result from
|
* host.c (pretty_print_address): Handle error result from
|
||||||
|
27
src/http.c
27
src/http.c
@ -1308,19 +1308,24 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
|
|||||||
request_set_header (req, "Proxy-Authorization", proxyauth, rel_value);
|
request_set_header (req, "Proxy-Authorization", proxyauth, rel_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Generate the Host header, HOST:PORT. Take into account that:
|
||||||
|
|
||||||
|
- Broken server-side software often doesn't recognize the PORT
|
||||||
|
argument, so we must generate "Host: www.server.com" instead of
|
||||||
|
"Host: www.server.com:80" (and likewise for https port).
|
||||||
|
|
||||||
|
- IPv6 addresses contain ":", so "Host: 3ffe:8100:200:2::2:1234"
|
||||||
|
becomes ambiguous and needs to be rewritten as "Host:
|
||||||
|
[3ffe:8100:200:2::2]:1234". */
|
||||||
{
|
{
|
||||||
/* Whether we need to print the host header with braces around
|
/* Formats arranged for hfmt[add_port][add_squares]. */
|
||||||
host, e.g. "Host: [3ffe:8100:200:2::2]:1234" instead of the
|
static const char *hfmt[][2] = {
|
||||||
usual "Host: symbolic-name:1234". */
|
{ "%s", "[%s]" }, { "%s:%d", "[%s]:%d" }
|
||||||
bool squares = strchr (u->host, ':') != NULL;
|
};
|
||||||
if (u->port == scheme_default_port (u->scheme))
|
int add_port = u->port != scheme_default_port (u->scheme);
|
||||||
|
int add_squares = strchr (u->host, ':') != NULL;
|
||||||
request_set_header (req, "Host",
|
request_set_header (req, "Host",
|
||||||
aprintf (squares ? "[%s]" : "%s", u->host),
|
aprintf (hfmt[add_port][add_squares], u->host, u->port),
|
||||||
rel_value);
|
|
||||||
else
|
|
||||||
request_set_header (req, "Host",
|
|
||||||
aprintf (squares ? "[%s]:%d" : "%s:%d",
|
|
||||||
u->host, u->port),
|
|
||||||
rel_value);
|
rel_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user