Skip to content

Commit

Permalink
fix h2 request_summary
Browse files Browse the repository at this point in the history
---
also add port number
---
also print query with path for h2 just as h1

Includes-commit: 2df4e29
Includes-commit: 53e1810
Includes-commit: 8102a09
Replicated-from: #345
  • Loading branch information
Congyuwang authored and andrewhavck committed Aug 9, 2024
1 parent 50c3687 commit a8111f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .bleep
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f123f5e43e9ada31a0e541b917ea674527fd06a3
352835e0dc76946e3fd5e8c536d5c080d0b1ddb6
17 changes: 12 additions & 5 deletions pingora-core/src/protocols/http/v2/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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()
)
}
Expand Down

0 comments on commit a8111f9

Please sign in to comment.