From 1606c4e9b4c1c5ead633ea2d058c743573fa0738 Mon Sep 17 00:00:00 2001 From: Max Bowsher Date: Wed, 11 Dec 2002 22:29:00 +0000 Subject: [PATCH] 2002-12-11 Abraham Backus * nio-http.cc (NetIO_HTTP::NetIO_HTTP): Leave port out of Host header, unless non-default. --- ChangeLog | 5 +++++ nio-http.cc | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 67ee286e..0b69e372 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-12-11 Abraham Backus + + * nio-http.cc (NetIO_HTTP::NetIO_HTTP): Leave port out of Host header, + unless non-default. + 2002-12-11 Max Bowsher * package_meta.cc: Change 'endl' to 'endLog' as appropriate. diff --git a/nio-http.cc b/nio-http.cc index 2dc563c2..9b54e76a 100644 --- a/nio-http.cc +++ b/nio-http.cc @@ -113,7 +113,14 @@ retry_get: s->printf ("GET %s HTTP/1.0\r\n", Purl); else s->printf ("GET %s HTTP/1.0\r\n", path); - s->printf ("Host: %s:%d\r\n", host, port); + + // Default HTTP port is 80. Host header can have no port if requested port + // is the same as the default. Some HTTP servers don't behave as expected + // when they receive a Host header with the unnecessary default port value. + if (port == 80) + s->printf ("Host: %s\r\n", host); + else + s->printf ("Host: %s:%d\r\n", host, port); if (net_user && net_passwd) s->printf ("Authorization: Basic %s\r\n", -- 2.43.5