mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 22:10:01 -04:00
let hyper send the host header
This commit is contained in:
parent
12cb93b018
commit
3941d2fad1
1 changed files with 1 additions and 16 deletions
|
@ -11,7 +11,7 @@ use futures_util::TryStreamExt;
|
||||||
use http::{
|
use http::{
|
||||||
header::{
|
header::{
|
||||||
InvalidHeaderName, InvalidHeaderValue, ACCEPT_ENCODING, CONNECTION, CONTENT_LENGTH,
|
InvalidHeaderName, InvalidHeaderValue, ACCEPT_ENCODING, CONNECTION, CONTENT_LENGTH,
|
||||||
CONTENT_TYPE, HOST, USER_AGENT,
|
CONTENT_TYPE, USER_AGENT,
|
||||||
},
|
},
|
||||||
method::InvalidMethod,
|
method::InvalidMethod,
|
||||||
uri::{InvalidUri, InvalidUriParts},
|
uri::{InvalidUri, InvalidUriParts},
|
||||||
|
@ -523,13 +523,8 @@ impl EpoxyClient {
|
||||||
&& let Some(mut new_req) = new_req
|
&& let Some(mut new_req) = new_req
|
||||||
&& let Some(location) = res.headers().get("Location")
|
&& let Some(location) = res.headers().get("Location")
|
||||||
&& let Ok(redirect_url) = new_req.uri().get_redirect(location)
|
&& let Ok(redirect_url) = new_req.uri().get_redirect(location)
|
||||||
&& let Some(redirect_url_authority) = redirect_url.clone().authority()
|
|
||||||
{
|
{
|
||||||
*new_req.uri_mut() = redirect_url;
|
*new_req.uri_mut() = redirect_url;
|
||||||
new_req.headers_mut().insert(
|
|
||||||
"Host",
|
|
||||||
HeaderValue::from_str(redirect_url_authority.as_str())?,
|
|
||||||
);
|
|
||||||
Ok(EpoxyResponse::Redirect((res, new_req)))
|
Ok(EpoxyResponse::Redirect((res, new_req)))
|
||||||
} else {
|
} else {
|
||||||
Ok(EpoxyResponse::Success(res))
|
Ok(EpoxyResponse::Success(res))
|
||||||
|
@ -575,12 +570,6 @@ impl EpoxyClient {
|
||||||
url.scheme_str().map(ToString::to_string),
|
url.scheme_str().map(ToString::to_string),
|
||||||
))?;
|
))?;
|
||||||
|
|
||||||
let host = url.host().ok_or(EpoxyError::NoUrlHost)?;
|
|
||||||
let port_str = url
|
|
||||||
.port_u16()
|
|
||||||
.map(|x| format!(":{}", x))
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let request_method = object_get(&options, "method")
|
let request_method = object_get(&options, "method")
|
||||||
.as_string()
|
.as_string()
|
||||||
.unwrap_or_else(|| "GET".to_string());
|
.unwrap_or_else(|| "GET".to_string());
|
||||||
|
@ -635,10 +624,6 @@ impl EpoxyClient {
|
||||||
}
|
}
|
||||||
headers_map.insert(CONNECTION, HeaderValue::from_static("keep-alive"));
|
headers_map.insert(CONNECTION, HeaderValue::from_static("keep-alive"));
|
||||||
headers_map.insert(USER_AGENT, HeaderValue::from_str(&self.user_agent)?);
|
headers_map.insert(USER_AGENT, HeaderValue::from_str(&self.user_agent)?);
|
||||||
headers_map.insert(
|
|
||||||
HOST,
|
|
||||||
HeaderValue::from_str(&format!("{}{}", host, port_str))?,
|
|
||||||
);
|
|
||||||
|
|
||||||
if let Some(content_type) = body_content_type {
|
if let Some(content_type) = body_content_type {
|
||||||
headers_map.insert(CONTENT_TYPE, HeaderValue::from_str(&content_type)?);
|
headers_map.insert(CONTENT_TYPE, HeaderValue::from_str(&content_type)?);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue