Skip to content

Commit

Permalink
Write non-80 port in HOST of client's request (actix#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh authored Aug 7, 2018
1 parent 954f1a0 commit 9c80d3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
9 changes: 8 additions & 1 deletion src/client/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 9c80d3a

Please sign in to comment.