Skip to content

Commit

Permalink
do not copy request path. (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow authored Apr 15, 2024
1 parent d6610b1 commit 7c4d40f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions client/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ impl From<crate::h3::Connection> for ConnectionShared {
#[derive(PartialEq, Eq, Debug, Clone, Hash)]
pub enum ConnectionKey {
Regular(Authority),
#[cfg(unix)]
Unix(AuthorityWithPath),
}

Expand Down Expand Up @@ -71,7 +70,6 @@ impl From<&Uri<'_>> for ConnectionKey {
fn from(uri: &Uri<'_>) -> Self {
match *uri {
Uri::Tcp(uri) | Uri::Tls(uri) => ConnectionKey::Regular(uri.authority().unwrap().clone()),
#[cfg(unix)]
Uri::Unix(uri) => ConnectionKey::Unix(AuthorityWithPath {
authority: uri.authority().unwrap().clone(),
path_and_query: uri.path_and_query().unwrap().clone(),
Expand Down
3 changes: 2 additions & 1 deletion client/src/pool/exclusive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ where
}
}

// acquire a connection from pool. if a new connection needs to be made
// acquire a connection from pool. if a new connection needs to be made a spawner type
// would be returned.
pub(crate) async fn acquire(&self, key: impl Into<K>) -> AcquireOutput<'_, K, C> {
let key = key.into();

Expand Down
10 changes: 7 additions & 3 deletions http/src/h1/proto/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ impl<D, const MAX_HEADERS: usize> Context<'_, D, MAX_HEADERS> {

let method = Method::from_bytes(req.method.unwrap().as_bytes())?;

let uri = req.path.unwrap().parse::<Uri>()?;

// default body decoder from method.
let mut decoder = match method {
// set method to context so it can pass method to response.
Expand All @@ -62,12 +60,18 @@ impl<D, const MAX_HEADERS: usize> Context<'_, D, MAX_HEADERS> {
// record indices of headers from bytes buffer.
let mut header_idx = uninit::uninit_array::<_, MAX_HEADERS>();
let header_idx_slice = HeaderIndex::record(&mut header_idx, buf, req.headers);

let headers_len = req.headers.len();

// record indices of request path from buffer.
let path = req.path.unwrap();
let path_head = path.as_ptr() as usize - buf.as_ptr() as usize;
let path_len = path.len();

// split the headers from buffer.
let slice = buf.split_to(len).freeze();

let uri = Uri::from_maybe_shared(slice.slice(path_head..path_head + path_len))?;

// pop a cached headermap or construct a new one.
let mut headers = self.take_headers();
headers.reserve(headers_len);
Expand Down

0 comments on commit 7c4d40f

Please sign in to comment.