Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not copy request path. #1022

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading