Skip to content

Need for Request to take a slice of MaybeUninit<Header> #95

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

Closed
Soveu opened this issue May 4, 2021 · 2 comments · Fixed by #98
Closed

Need for Request to take a slice of MaybeUninit<Header> #95

Soveu opened this issue May 4, 2021 · 2 comments · Fixed by #98

Comments

@Soveu
Copy link
Contributor

Soveu commented May 4, 2021

Context: hyper passes uninitialized array of httparse::Header to Request::new.
This is undefined behavior and I discovered it while working on Replacing mem::uninitialized with MaybeUninit

I acknowledge that changing headers field will be a breaking change, because it is public, so
is there a chance that a Request type copy could be implemented, but with headers: &mut [MaybeUninit<Header>]?

EDIT: I just realized that author of httparse is also author of hyper 😅

@seanmonstar
Copy link
Owner

Yea, I allow this in hyper knowing that httparse can never look at the values, but it would be better to be explicit about it. It would be a breaking change, that's true. I haven't spent much time thinking about how to fix it in this repo, and instead just promise myself that the slice can never be inspected 🤷

@Soveu
Copy link
Contributor Author

Soveu commented May 5, 2021

Or we can just introduce a function that would just take buffer and parse immediately, it would fit for hyper

fn with_uninit_buffer_and_parse(headers: &mut [MaybeUninit<Header>]) -> (Request, Result<usize>)

I have already adjusted parse_headers_iter to use this type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants