Closed Soveu closed 3 years ago
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 :shrug:
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
Context:
hyper
passes uninitialized array ofhttparse::Header
toRequest::new
. This is undefined behavior and I discovered it while working on Replacingmem::uninitialized
withMaybeUninit
I acknowledge that changing
headers
field will be a breaking change, because it is public, so is there a chance that aRequest
type copy could be implemented, but withheaders: &mut [MaybeUninit<Header>]
?EDIT: I just realized that author of
httparse
is also author ofhyper
:sweat_smile: