mirror of
https://github.com/cloudflare/pingora.git
synced 2024-09-20 02:31:35 +02:00
Add a convenience function to retrieve Session digest
This commit is contained in:
parent
cfb86c3f16
commit
7b838b8118
3 changed files with 13 additions and 6 deletions
2
.bleep
2
.bleep
|
@ -1 +1 @@
|
|||
c0a9b66dfde7c081c6f9153677af66f619aee158
|
||||
fa95ba9cdfb9a347913e0cffbb84ca003833ccaa
|
|
@ -18,7 +18,7 @@ use super::error_resp;
|
|||
use super::v1::server::HttpSession as SessionV1;
|
||||
use super::v2::server::HttpSession as SessionV2;
|
||||
use super::HttpTask;
|
||||
use crate::protocols::{SocketAddr, Stream};
|
||||
use crate::protocols::{Digest, SocketAddr, Stream};
|
||||
use bytes::Bytes;
|
||||
use http::header::AsHeaderName;
|
||||
use http::HeaderValue;
|
||||
|
@ -339,6 +339,14 @@ impl Session {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return the digest for the session.
|
||||
pub fn digest(&self) -> Option<&Digest> {
|
||||
match self {
|
||||
Self::H1(s) => Some(s.digest()),
|
||||
Self::H2(s) => s.digest(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the client (peer) address of the connnection.
|
||||
pub fn client_addr(&self) -> Option<&SocketAddr> {
|
||||
match self {
|
||||
|
|
|
@ -52,8 +52,7 @@ pub struct HttpSession {
|
|||
pub(crate) digest: Box<Digest>,
|
||||
response_header: Option<Box<ResponseHeader>>,
|
||||
request_written: Option<Box<RequestHeader>>,
|
||||
// request body bytes written to upstream
|
||||
body_bytes_sent: usize,
|
||||
bytes_sent: usize,
|
||||
upgraded: bool,
|
||||
}
|
||||
|
||||
|
@ -78,10 +77,10 @@ impl HttpSession {
|
|||
keepalive_timeout: KeepaliveStatus::Off,
|
||||
response_header: None,
|
||||
request_written: None,
|
||||
body_bytes_sent: 0,
|
||||
read_timeout: None,
|
||||
write_timeout: None,
|
||||
digest,
|
||||
bytes_sent: 0,
|
||||
upgraded: false,
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +127,7 @@ impl HttpSession {
|
|||
.await;
|
||||
|
||||
if let Ok(Some(num_bytes)) = written {
|
||||
self.body_bytes_sent += num_bytes;
|
||||
self.bytes_sent += num_bytes;
|
||||
}
|
||||
|
||||
written
|
||||
|
|
Loading…
Reference in a new issue