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

Please increase the demo number of headers #70

Closed
jrconlin opened this issue Apr 15, 2020 · 3 comments
Closed

Please increase the demo number of headers #70

jrconlin opened this issue Apr 15, 2020 · 3 comments

Comments

@jrconlin
Copy link

tldr: Please change the documentation demo line from

let mut headers = [httparse::EMPTY_HEADER; 16];
let mut req = httparse::Request::new(&mut headers);

to

let mut headers = [httparse::EMPTY_HEADER; 64];
let mut req = httparse::Request::new(&mut headers);

This is a really silly bug that bit us.

Our server uses httparse. Since we weren't quite sure how many headers we needed to pre-allocate, we used the demo code's suggested 16 headers. Unfortunately, with work going on around the new Sec-* headers, we suddenly saw a spike of clients trying to connect with 17 headers. It took us a bit to figure out what was going on and why these connections were mysteriously failing.

Boosting the count might help others not suddenly hit this problem.

@miketaylr
Copy link
Contributor

@jrconlin I see 64 here, https://docs.rs/httparse/1.3.4/httparse/constant.EMPTY_HEADER.html#example

Is there anywhere else 16 is listed, beyond the README.md, that you're aware of?

@jrconlin
Copy link
Author

Not that I'm aware of, no. However, I've not really done a very deep dive to investigate. It's my guess that we used 16 mostly from the README example, but it's been a while and folks forgot where they got the number.

@ylxdzsw
Copy link

ylxdzsw commented Apr 24, 2020

Got the same problem too. The fact that Chrome sent more headers than cURL and exceeded the pre-allocated number of headers really confused us for a while.

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

No branches or pull requests

4 participants