Header override bugfix
This commit is contained in:
@@ -169,12 +169,16 @@ impl From<actix_web::HttpRequest> for HttpRequest {
|
||||
.map(|x| x.to_string())
|
||||
.unwrap_or_else(|| req.uri().path().to_string());
|
||||
|
||||
let headers: Vec<(String, String)> = req
|
||||
let mut headers: Vec<(String, String)> = req
|
||||
.headers()
|
||||
.iter()
|
||||
.map(|(k, v)| (k.to_string(), v.to_str().unwrap_or("").to_string()))
|
||||
.collect();
|
||||
|
||||
if !req.headers().contains_key("Host") {
|
||||
headers.push(("Host".to_owned(), req.connection_info().host().to_owned()));
|
||||
}
|
||||
|
||||
Self {
|
||||
method,
|
||||
path,
|
||||
|
||||
@@ -4,6 +4,7 @@ use bytes::Bytes;
|
||||
use reqwest::{
|
||||
Method,
|
||||
header::{HeaderMap, HeaderName, HeaderValue},
|
||||
redirect::Policy,
|
||||
};
|
||||
|
||||
use crate::settings::Result;
|
||||
@@ -18,14 +19,17 @@ pub struct ReqwestProxy {
|
||||
impl ServerProxyService for ReqwestProxy {
|
||||
async fn new() -> Arc<Self> {
|
||||
Self {
|
||||
client: reqwest::Client::new(),
|
||||
client: reqwest::ClientBuilder::new()
|
||||
.redirect(Policy::none())
|
||||
.build()
|
||||
.expect("Can't build client"),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
async fn fetch(&self, req: HttpRequest, connection: Connection) -> Result<HttpResponse> {
|
||||
let mut headers = HeaderMap::new();
|
||||
for (key, value) in req.headers {
|
||||
headers.insert(key.parse::<HeaderName>()?, value.parse::<HeaderValue>()?);
|
||||
headers.append(key.parse::<HeaderName>()?, value.parse::<HeaderValue>()?);
|
||||
}
|
||||
let res = self
|
||||
.client
|
||||
|
||||
Reference in New Issue
Block a user