nghttpx: Omit well-known port from hostport in downstream request

This commit is contained in:
Tatsuhiro Tsujikawa 2015-03-13 23:01:55 +09:00
parent de0543f684
commit 7b90404072
3 changed files with 9 additions and 3 deletions

View File

@ -506,6 +506,10 @@ int Http2Session::downstream_connect_proxy() {
std::string req = "CONNECT ";
req += downstream_addr.hostport.get();
if (downstream_addr.port == 80 || downstream_addr.port == 443) {
req += ":";
req += util::utos(downstream_addr.port);
}
req += " HTTP/1.1\r\nHost: ";
req += downstream_addr.host.get();
req += "\r\n";

View File

@ -1038,8 +1038,10 @@ std::string make_hostport(const char *host, uint16_t port) {
hostport += "]";
}
hostport += ":";
hostport += utos(port);
if (port != 80 && port != 443) {
hostport += ":";
hostport += utos(port);
}
return hostport;
}

View File

@ -609,7 +609,7 @@ std::string format_duration(const std::chrono::microseconds &u);
// Creates "host:port" string using given |host| and |port|. If
// |host| is numeric IPv6 address (e.g., ::1), it is enclosed by "["
// and "]".
// and "]". If |port| is 80 or 443, port part is omitted.
std::string make_hostport(const char *host, uint16_t port);
} // namespace util