sinsanarya
sinsanarya

Reputation: 73

maxhttpHeaderSize in spring boot tomcat

I need to limit the header size of request to 16KB in spring boot. I added the maxHttpHeaderSize flag to 16000 to do this. I noticed that when I make a call from postman to test this out, the request starts failing(Request header is too large) from the time the header size is around 15KB. I was wondering what happens to the other 1KB?

Upvotes: 1

Views: 1760

Answers (1)

Forketyfork
Forketyfork

Reputation: 7810

This might be an issue with confusion of what a KB means. In your case, it's most likely the Base 2 value, which is 1024, not 1000. This means that 16000 bytes are actually around 15.7KB.

You can set the maxHttpHeaderSize either to 16 * 1024 = 16384, or just to 16KB, which should work if you have Spring Boot 2.1+

Also, this value limits not just one particular header field size, but the full HTTP header, including all field names and values. Postman may also include some hidden headers, like Host, Content-Size, User-Agent, etc.

Upvotes: 1

Related Questions