summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMalte Starostik2011-07-15 16:31:56 +0200
committerMichael Brown2011-07-15 17:46:58 +0200
commit69b7d57265679d76e26581d034e8f8ab5168bb27 (patch)
tree0b8f11582156d520e1bbaf529a5f048fbb937aef /src
parent[igb] Remove __BIG_ENDIAN conditional (diff)
downloadipxe-69b7d57265679d76e26581d034e8f8ab5168bb27.tar.gz
ipxe-69b7d57265679d76e26581d034e8f8ab5168bb27.tar.xz
ipxe-69b7d57265679d76e26581d034e8f8ab5168bb27.zip
[http] Include port in HTTP Host header as needed
According to section 14.23 of RFC2616, an HTTP Host header without port implies the default port is used. Thus, when fetching from anywhere but port 80 for HTTP or 443 for HTTPS, the port ought to be explicitly given in that header. Otherwise, some servers might fail to associate the request with the correct virtual host or generate incorrect self-referencing URLs. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src')
-rw-r--r--src/net/tcp/http.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/net/tcp/http.c b/src/net/tcp/http.c
index 012b2268..cee75133 100644
--- a/src/net/tcp/http.c
+++ b/src/net/tcp/http.c
@@ -662,13 +662,17 @@ static void http_step ( struct http_request *http ) {
if ( ( rc = xfer_printf ( &http->socket,
"%s %s%s HTTP/1.1\r\n"
"User-Agent: iPXE/" VERSION "\r\n"
- "Host: %s\r\n"
+ "Host: %s%s%s\r\n"
"%s%s%s%s%s%s%s"
"\r\n",
( ( http->flags & HTTP_HEAD_ONLY ) ?
"HEAD" : "GET" ),
( http->uri->path ? "" : "/" ),
request, host,
+ ( http->uri->port ?
+ ":" : "" ),
+ ( http->uri->port ?
+ http->uri->port : "" ),
( ( http->flags & HTTP_KEEPALIVE ) ?
"Connection: Keep-Alive\r\n" : "" ),
( partial ? "Range: bytes=" : "" ),