1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

Write non-80 port in HOST of client's request (#451)

This commit is contained in:
Douman 2018-08-07 10:01:29 +03:00 committed by GitHub
parent 954f1a0b0f
commit 9c80d3aa77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -19,6 +19,7 @@
* Fix adding multiple response headers #446 * 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 ## [0.7.3] - 2018-08-01

View File

@ -629,7 +629,14 @@ impl ClientRequestBuilder {
if let Some(parts) = parts(&mut self.request, &self.err) { if let Some(parts) = parts(&mut self.request, &self.err) {
if let Some(host) = parts.uri.host() { if let Some(host) = parts.uri.host() {
if !parts.headers.contains_key(header::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) => { Ok(value) => {
parts.headers.insert(header::HOST, value); parts.headers.insert(header::HOST, value);
} }