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

Use new methods for parsing with uninitialized headers from httparse #2545

Merged
merged 7 commits into from
Aug 19, 2021
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Server::parse - use MaybeUninit
Soveu committed May 11, 2021

Verified

This commit was signed with the committer’s verified signature. The key has expired.
commit 7500d7ddfd1c39a5fbfefd54b9014842d9862af4
9 changes: 6 additions & 3 deletions src/proto/h1/role.rs
Original file line number Diff line number Diff line change
@@ -129,15 +129,18 @@ impl Http1Transaction for Server {
MaybeUninit::uninit().assume_init()
};
{
let mut headers: [httparse::Header<'_>; MAX_HEADERS] = unsafe { mem::uninitialized() };
/* SAFETY: it is safe to go from MaybeUninit array to array of MaybeUninit */
let mut headers: [MaybeUninit<httparse::Header<'_>>; MAX_HEADERS] = unsafe {
MaybeUninit::uninit().assume_init()
};
trace!(
"Request.parse([Header; {}], [u8; {}])",
headers.len(),
buf.len()
);
let mut req = httparse::Request::new(&mut headers);
let bytes = buf.as_ref();
match req.parse(bytes) {
let (req, status) = httparse::Request::with_uninit_headers(&mut headers, bytes);
match status {
Ok(httparse::Status::Complete(parsed_len)) => {
trace!("Request.parse Complete({})", parsed_len);
len = parsed_len;