perf: optimize header handling and concurrent access patterns

This commit is contained in:
Ara Sadoyan
2025-12-10 19:09:04 +01:00
parent a43bccdfb8
commit 0fc79c022f
6 changed files with 46 additions and 25 deletions

View File

@@ -2,11 +2,12 @@ use crate::utils::structs::InnerMap;
use crate::web::proxyhttp::LB;
use async_trait::async_trait;
use std::sync::atomic::Ordering;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct GetHostsReturHeaders {
pub client_headers: Option<Vec<(String, String)>>,
pub server_headers: Option<Vec<(String, String)>>,
pub client_headers: Option<Vec<(Arc<str>, Arc<str>)>>,
pub server_headers: Option<Vec<(Arc<str>, Arc<str>)>>,
}
#[async_trait]

View File

@@ -191,7 +191,7 @@ impl ProxyHttp for LB {
if let Some(headers) = self.get_header(ctx.hostname.as_ref().unwrap_or(&Arc::from("localhost")), session.req_header().uri.path()) {
if let Some(server_headers) = headers.server_headers {
for k in server_headers {
upstream_request.insert_header(k.0, k.1)?;
upstream_request.insert_header(k.0.to_string(), k.1.as_ref())?;
}
}
if let Some(client_headers) = headers.client_headers {