mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
do not override HOST header for client request #428
This commit is contained in:
parent
2072c933ba
commit
4dba531bf9
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
* Support HTTP/2 with rustls #36
|
* Support HTTP/2 with rustls #36
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Do not override HOST header for client request #428
|
||||||
|
|
||||||
|
|
||||||
## [0.7.2] - 2018-07-26
|
## [0.7.2] - 2018-07-26
|
||||||
|
|
||||||
|
@ -291,10 +291,6 @@ impl ClientRequestBuilder {
|
|||||||
fn _uri(&mut self, url: &str) -> &mut Self {
|
fn _uri(&mut self, url: &str) -> &mut Self {
|
||||||
match Uri::try_from(url) {
|
match Uri::try_from(url) {
|
||||||
Ok(uri) => {
|
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) {
|
if let Some(parts) = parts(&mut self.request, &self.err) {
|
||||||
parts.uri = uri;
|
parts.uri = uri;
|
||||||
}
|
}
|
||||||
@ -629,9 +625,24 @@ impl ClientRequestBuilder {
|
|||||||
self.set_header_if_none(header::ACCEPT_ENCODING, "gzip, deflate");
|
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(
|
self.set_header_if_none(
|
||||||
header::USER_AGENT,
|
header::USER_AGENT,
|
||||||
concat!("Actix-web/", env!("CARGO_PKG_VERSION")),
|
concat!("actix-web/", env!("CARGO_PKG_VERSION")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user