diff --git a/CHANGES.md b/CHANGES.md index 714e6b67c..eff8d4cf7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,7 @@ * Added `HttpServer::maxconn()` and `HttpServer::maxconnrate()`, accept backpressure #250 -* Allow to customize connection handshake process via `HttpServer::listen_with()` +* Allow to customize connection handshake process via `HttpServer::listen_with()` and `HttpServer::bind_with()` methods ### Fixed @@ -19,6 +19,7 @@ * Fix adding multiple response headers #446 +* Client includes port in HOST header when it is not default(e.g. not 80 and 443). #448 ## [0.7.3] - 2018-08-01 diff --git a/src/client/request.rs b/src/client/request.rs index 4d506c3fa..aff4ab485 100644 --- a/src/client/request.rs +++ b/src/client/request.rs @@ -629,7 +629,14 @@ impl ClientRequestBuilder { if let Some(parts) = parts(&mut self.request, &self.err) { if let Some(host) = parts.uri.host() { if !parts.headers.contains_key(header::HOST) { - match host.try_into() { + let mut wrt = BytesMut::with_capacity(host.len() + 5).writer(); + + let _ = match parts.uri.port() { + None | Some(80) | Some(443) => write!(wrt, "{}", host), + Some(port) => write!(wrt, "{}:{}", host, port), + }; + + match wrt.get_mut().take().freeze().try_into() { Ok(value) => { parts.headers.insert(header::HOST, value); }