fix h2 request_summary

---
also add port number
---
also print query with path for h2 just as h1

Includes-commit: 2df4e29e18
Includes-commit: 53e1810a27
Includes-commit: 8102a0900b
Replicated-from: https://github.com/cloudflare/pingora/pull/345
This commit is contained in:
Congyu WANG 2024-08-07 07:36:06 +00:00 committed by Edward Wang
parent 50c3687e83
commit a1f7b62367
2 changed files with 13 additions and 6 deletions

2
.bleep
View file

@ -1 +1 @@
f123f5e43e9ada31a0e541b917ea674527fd06a3
352835e0dc76946e3fd5e8c536d5c080d0b1ddb6

View file

@ -20,6 +20,7 @@ use h2::server;
use h2::server::SendResponse;
use h2::{RecvStream, SendStream};
use http::header::HeaderName;
use http::uri::PathAndQuery;
use http::{header, HeaderMap, Response};
use log::{debug, warn};
use pingora_http::{RequestHeader, ResponseHeader};
@ -346,13 +347,19 @@ impl HttpSession {
/// Return a string `$METHOD $PATH $HOST`. Mostly for logging and debug purpose
pub fn request_summary(&self) -> String {
format!(
"{} {}, Host: {}",
"{} {}, Host: {}:{}",
self.request_header.method,
self.request_header.uri,
self.request_header
.headers
.get(header::HOST)
.map(|v| String::from_utf8_lossy(v.as_bytes()))
.uri
.path_and_query()
.map(PathAndQuery::as_str)
.unwrap_or_default(),
self.request_header.uri.host().unwrap_or_default(),
self.req_header()
.uri
.port()
.as_ref()
.map(|port| port.as_str())
.unwrap_or_default()
)
}