mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +01:00
Write non-80 port in HOST of client's request (#451)
This commit is contained in:
parent
954f1a0b0f
commit
9c80d3aa77
@ -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
|
||||||
|
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user