v0.34.0_6
This commit is contained in:
1 parent
5910e6e901
commit
47ce1f18c2
18 files changed
+364
-69
No files matched your search
@@ -1,5 +1,20 @@
|
||||
include!("request_id.rs");
|
||||
|
||||
// Retain the exchange through the response, but do not allocate an additional
|
||||
// body adapter for a request whose body has no frames or trailers.
|
||||
fn wrap_observed_request(body: Body, exchange: &Arc<Exchange>, idle: Duration) -> Body {
|
||||
if body.is_end_stream() { body }
|
||||
else { Body::new(MeteredBody::new(body, exchange.clone(), Direction::Request, idle)) }
|
||||
}
|
||||
|
||||
fn log_prefix(input: &str, max_chars: usize) -> String {
|
||||
if input.len() <= max_chars || input.is_ascii() {
|
||||
input[..input.len().min(max_chars)].to_owned()
|
||||
} else {
|
||||
input.chars().take(max_chars).collect()
|
||||
}
|
||||
}
|
||||
|
||||
fn should_replace_error_page(response: &Response, minimal_welcome: bool) -> bool {
|
||||
!minimal_welcome
|
||||
&& response
|
||||
@@ -117,14 +132,12 @@ async fn observe(State(state): State<Arc<App>>, mut request: Request, next: Next
|
||||
if let Some(frontend) = &frontend_context {
|
||||
frontend.metrics.active.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
let host = request
|
||||
.headers()
|
||||
.get(HOST)
|
||||
.and_then(|h| h.to_str().ok())
|
||||
.unwrap_or_else(|| request.uri().authority().map(|v| v.as_str()).unwrap_or(""))
|
||||
.chars()
|
||||
.take(253)
|
||||
.collect();
|
||||
let host = log_prefix(
|
||||
request.headers().get(HOST)
|
||||
.and_then(|h| h.to_str().ok())
|
||||
.unwrap_or_else(|| request.uri().authority().map(|v| v.as_str()).unwrap_or("")),
|
||||
253,
|
||||
);
|
||||
let initial_client_ip = request
|
||||
.extensions()
|
||||
.get::<PeerAddr>()
|
||||
@@ -164,7 +177,7 @@ async fn observe(State(state): State<Arc<App>>, mut request: Request, next: Next
|
||||
request_id: request_id.clone(),
|
||||
method: request.method().to_string(),
|
||||
host,
|
||||
path: request.uri().path().chars().take(256).collect(),
|
||||
path: log_prefix(request.uri().path(), 256),
|
||||
http_version,
|
||||
transport,
|
||||
websocket_bootstrap,
|
||||
@@ -200,14 +213,7 @@ async fn observe(State(state): State<Arc<App>>, mut request: Request, next: Next
|
||||
.as_ref()
|
||||
.and_then(|frontend| frontend.proxy_timeouts.send_timeout())
|
||||
.unwrap_or(state.body_idle_timeout);
|
||||
let request = request.map(|body| {
|
||||
Body::new(MeteredBody::new(
|
||||
body,
|
||||
exchange.clone(),
|
||||
Direction::Request,
|
||||
request_send_timeout,
|
||||
))
|
||||
});
|
||||
let request = request.map(|body| wrap_observed_request(body, &exchange, request_send_timeout));
|
||||
let mut response = next.run(request).await;
|
||||
let final_route_context = response
|
||||
.extensions()
|
||||
|
||||
Reference in new issue
Block a user