1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-30 18:34:36 +01:00

Ensure that awc::ws::WebsocketsRequest sets the Host header (#1070)

* Ensure that awc::ws::WebsocketsRequest sets the Host header before connecting.

* Make sure to check if headers already have a HOST value before setting

* Update CHANGES.md to reflect WebSocket client update.
This commit is contained in:
Eugene Bulkin 2019-09-09 01:27:13 -05:00 committed by Nikolay Kim
parent 8a9fcddb3c
commit 8d61fe0925
2 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,11 @@
# Changes # Changes
## [0.2.5] - 2019-09-06
### Changed
* Ensure that the `Host` header is set when initiating a WebSocket client connection.
## [0.2.4] - 2019-08-13 ## [0.2.4] - 2019-08-13
### Changed ### Changed

View File

@ -233,6 +233,10 @@ impl WebsocketsRequest {
return Either::A(err(InvalidUrl::UnknownScheme.into())); return Either::A(err(InvalidUrl::UnknownScheme.into()));
} }
if !self.head.headers.contains_key(header::HOST) {
self.head.headers.insert(header::HOST, HeaderValue::from_str(uri.host().unwrap()).unwrap());
}
// set cookies // set cookies
if let Some(ref mut jar) = self.cookies { if let Some(ref mut jar) = self.cookies {
let mut cookie = String::new(); let mut cookie = String::new();