mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 03:21:08 +00:00
do not override HOST header for client request #428
This commit is contained in:
parent
2072c933ba
commit
4dba531bf9
2 changed files with 20 additions and 5 deletions
|
@ -6,6 +6,10 @@
|
|||
|
||||
* Support HTTP/2 with rustls #36
|
||||
|
||||
### Fixed
|
||||
|
||||
* Do not override HOST header for client request #428
|
||||
|
||||
|
||||
## [0.7.2] - 2018-07-26
|
||||
|
||||
|
|
|
@ -291,10 +291,6 @@ impl ClientRequestBuilder {
|
|||
fn _uri(&mut self, url: &str) -> &mut Self {
|
||||
match Uri::try_from(url) {
|
||||
Ok(uri) => {
|
||||
// set request host header
|
||||
if let Some(host) = uri.host() {
|
||||
self.set_header(header::HOST, host);
|
||||
}
|
||||
if let Some(parts) = parts(&mut self.request, &self.err) {
|
||||
parts.uri = uri;
|
||||
}
|
||||
|
@ -629,9 +625,24 @@ impl ClientRequestBuilder {
|
|||
self.set_header_if_none(header::ACCEPT_ENCODING, "gzip, deflate");
|
||||
}
|
||||
|
||||
// set request host header
|
||||
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() {
|
||||
Ok(value) => {
|
||||
parts.headers.insert(header::HOST, value);
|
||||
}
|
||||
Err(e) => self.err = Some(e.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// user agent
|
||||
self.set_header_if_none(
|
||||
header::USER_AGENT,
|
||||
concat!("Actix-web/", env!("CARGO_PKG_VERSION")),
|
||||
concat!("actix-web/", env!("CARGO_PKG_VERSION")),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue