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

What's the maximum header size limit? #3283

Open
bagder opened this issue Aug 3, 2023 · 8 comments
Open

What's the maximum header size limit? #3283

bagder opened this issue Aug 3, 2023 · 8 comments
Labels
C-bug Category: bug. Something is wrong. This is bad!

Comments

@bagder
Copy link
Contributor

bagder commented Aug 3, 2023

Version
current from master

Platform
Linux

Description
I'm using hyper in curl, and when I receive a HTTP/1 response with many response headers, hyper cuts off the response and returns an error due to message head is too large. (With a HYPERE_INVALID_PEER_MESSAGE error)

I cannot find what this exact limit is. I can't even find it in the hyper source code.

@bagder bagder added the C-bug Category: bug. Something is wrong. This is bad! label Aug 3, 2023
@seanmonstar
Copy link
Member

To be more specific, are you asking about the list of headers, or the length of any single header? If receiving a lot of headers, the current limit of name/value pairs in hyper is 100. That was picked somewhat arbitrarily, and could be increased if more than that were common, but so far no one has ever needed it 🤷 .

@bagder
Copy link
Contributor Author

bagder commented Aug 4, 2023

Thanks for this.

I can't tell you what's right but it seems Firefox, Chrome (and curl) all accept name/value pairs all the way until they reach the maximum response header size. Which seems to be limited to somewhere between 256KB and 1MB.

@ajgh1
Copy link

ajgh1 commented Sep 14, 2023

I'm not sure about client-side, but Apache httpd 2.4's default LimitRequestFields (100) and LimitRequestFieldSize (8190) settings imply if a request's headers go much over 800KB, default httpd configurations will reject it. These limits can be changed of course, but the manual cautions that should not be necessary under normal circumstances.

@c-antin
Copy link

c-antin commented Oct 26, 2023

To be more specific, are you asking about the list of headers, or the length of any single header? If receiving a lot of headers, the current limit of name/value pairs in hyper is 100. That was picked somewhat arbitrarily, and could be increased if more than that were common, but so far no one has ever needed it 🤷 .

Does this MAX_HEADERS of 100 also apply for http2 requests (server-side)?
And is there a server-side size limit for each individual header including url size (for http2)?

@seanmonstar
Copy link
Member

No, that limit is for the HTTP/1 decoder. HTTP/2 has a setting that you can send, SETTINGS_MAX_HEADER_LIST_SIZE , to tell peer how much you're willing to accept, and hyper will enforce it for you.

@f3lixding
Copy link

the current limit of name/value pairs in hyper is 100. That was picked somewhat arbitrarily, and could be increased if more than that were common, but so far no one has ever needed it

I ran into the same problem (message head is too large) for reqwest and I found my way here to this thread.
Just wanted to +1 on this. It would be fantastic if we can have the MAX_HEADERS be configurable.

@Millione
Copy link

need to be increased or can be configurable.

@PureWhiteWu
Copy link

Hi, we've encountered same problem here. Our HTTP request has 100+ headers and hyper failed with error.

Is there any plan to make it configurable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug. Something is wrong. This is bad!
Projects
None yet
Development

No branches or pull requests

7 participants