hyper icon indicating copy to clipboard operation
hyper copied to clipboard

What's the maximum header size limit?

Open bagder opened this issue 2 years ago • 8 comments

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 avatar Aug 03 '23 11:08 bagder

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 🤷 .

seanmonstar avatar Aug 03 '23 17:08 seanmonstar

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.

bagder avatar Aug 04 '23 06:08 bagder

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.

ajgh1 avatar Sep 14 '23 04:09 ajgh1

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)?

c-antin avatar Oct 26 '23 12:10 c-antin

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.

seanmonstar avatar Oct 26 '23 14:10 seanmonstar

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.

f3lixding avatar Oct 27 '23 22:10 f3lixding

need to be increased or can be configurable.

Millione avatar Jan 12 '24 09:01 Millione

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?

PureWhiteWu avatar Jan 12 '24 10:01 PureWhiteWu