TL;DR
Just add a line like below in your application.properties file:
server.max-http-header-size=64kb
This sets the limit header size to 64 kilobytes.
What are HTTP headers?
According to Mozilla an HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response. For example, a request message can use headers to indicate its preferred media formats, while a response can use header to indicate the media format of the returned body.
Why Spring Boot limit the header size?
Well, large headers will consume more memory, they can slow down the request or worst crash our server. Limit them is a safety approach.
Under the hood Spring Boot is not a server, indeed Spring can embedded 3 distinct servers, Tomcat, Jetty or Undertow. However, the configuration for them will be the same.
The default header size are:
- Tomcat = 8kb
- Jetty = 8kb
- Undertow = 1mb
To change the max size, follow the TL;DR example.
Be careful when increasing the size limit always analise your situation and try to understand why the header is too large (usually are auth token).
Top comments (3)
What's in your headers to be so large?! 😯
Auth token, request trace id and others security things
It is the problem with browser,Which is automatically sending you request with https instead of http.Try in different browsers.It will work for sure