|
|
|
@ -548,6 +548,7 @@ impl Service { |
|
|
|
|
|
|
|
|
|
async fn handle_request( |
|
|
|
|
&self, |
|
|
|
|
proxy_client: sync::Arc<service::http::proxy::Client>, |
|
|
|
|
client_ip: net::IpAddr, |
|
|
|
|
req: Request, |
|
|
|
|
req_is_https: bool, |
|
|
|
@ -614,6 +615,7 @@ impl Service { |
|
|
|
|
let http_url = config.http_url.as_ref().unwrap(); |
|
|
|
|
|
|
|
|
|
return service::http::proxy::serve_http_request( |
|
|
|
|
proxy_client.as_ref(), |
|
|
|
|
http_url.original_url.as_str(), |
|
|
|
|
&config.http_request_headers.0, |
|
|
|
|
client_ip, |
|
|
|
@ -667,6 +669,7 @@ fn strip_port(host: &str) -> &str { |
|
|
|
|
|
|
|
|
|
struct HyperServiceImpl { |
|
|
|
|
service: sync::Arc<Service>, |
|
|
|
|
proxy_client: sync::Arc<service::http::proxy::Client>, |
|
|
|
|
client_ip: net::IpAddr, |
|
|
|
|
is_https: bool, |
|
|
|
|
} |
|
|
|
@ -675,6 +678,7 @@ impl HyperServiceImpl { |
|
|
|
|
pub fn new(service: sync::Arc<Service>, client_ip: net::IpAddr, is_https: bool) -> Self { |
|
|
|
|
Self { |
|
|
|
|
service, |
|
|
|
|
proxy_client: service::http::proxy::new_client().into(), |
|
|
|
|
client_ip, |
|
|
|
|
is_https, |
|
|
|
|
} |
|
|
|
@ -688,8 +692,13 @@ impl hyper::service::Service<Request> for HyperServiceImpl { |
|
|
|
|
|
|
|
|
|
fn call(&self, req: Request) -> Self::Future { |
|
|
|
|
let service = self.service.clone(); |
|
|
|
|
let proxy_client = self.proxy_client.clone(); |
|
|
|
|
let client_ip = self.client_ip; |
|
|
|
|
let is_https = self.is_https; |
|
|
|
|
Box::pin(async move { Ok(service.handle_request(client_ip, req, is_https).await) }) |
|
|
|
|
Box::pin(async move { |
|
|
|
|
Ok(service |
|
|
|
|
.handle_request(proxy_client, client_ip, req, is_https) |
|
|
|
|
.await) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|