Explorar el Código

[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>
tags/v1.20.1
Malte Starostik hace 13 años
padre
commit
69b7d57265
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5
    1
      src/net/tcp/http.c

+ 5
- 1
src/net/tcp/http.c Ver fichero

@@ -662,13 +662,17 @@ static void http_step ( struct http_request *http ) {
662 662
 	if ( ( rc = xfer_printf ( &http->socket,
663 663
 				  "%s %s%s HTTP/1.1\r\n"
664 664
 				  "User-Agent: iPXE/" VERSION "\r\n"
665
-				  "Host: %s\r\n"
665
+				  "Host: %s%s%s\r\n"
666 666
 				  "%s%s%s%s%s%s%s"
667 667
 				  "\r\n",
668 668
 				  ( ( http->flags & HTTP_HEAD_ONLY ) ?
669 669
 				    "HEAD" : "GET" ),
670 670
 				  ( http->uri->path ? "" : "/" ),
671 671
 				  request, host,
672
+				  ( http->uri->port ?
673
+				    ":" : "" ),
674
+				  ( http->uri->port ?
675
+				    http->uri->port : "" ),
672 676
 				  ( ( http->flags & HTTP_KEEPALIVE ) ?
673 677
 				    "Connection: Keep-Alive\r\n" : "" ),
674 678
 				  ( partial ? "Range: bytes=" : "" ),

Loading…
Cancelar
Guardar