Header override bugfix

This commit is contained in:
Fasterino
2025-10-31 06:51:23 +03:00
parent 9da8fe9889
commit 5ee87f15e7
3 changed files with 11 additions and 3 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -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,

View File

@@ -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