Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set max-http-header-size in spring boot 2.x application

I have Spring boot app running Java 11:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

And I am getting the error: java.lang.IllegalArgumentException: Request header is too large

How to increase max-http-header-size?

like image 426
Mindaugas Jaraminas Avatar asked Sep 11 '19 12:09

Mindaugas Jaraminas


People also ask

How do I change the maximum HTTP header size in spring boot?

The HTTP header values are restricted by server implementations. In a Spring Boot application, the max HTTP header size is configured using server. max-http-header-size. The actual default value for Tomcat and Jetty is 8kB, and the default value for Undertow is 1MB.

What is the maximum size of HTTP header values?

No, HTTP does not define any limit. However most web servers do limit size of headers they accept. For example in Apache default limit is 8KB, in IIS it's 16K. Server will return 413 Entity Too Large error if headers size exceeds that limit.

What is HTTP header size?

The default HTTP Request Header value is 8190 bytes.


4 Answers

You should set on the "application.properties" file:

server.max-http-header-size=48000

48000 is an example of an excessive header, put whatever you want.

like image 67
Vicent Morera Orchilles Avatar answered Oct 22 '22 01:10

Vicent Morera Orchilles


From Spring boot 2.1, you will now need to use a DataSize parsable value. e.g.

server.max-http-header-size=40KB
like image 33
Mannie Avatar answered Oct 21 '22 23:10

Mannie


Please try server.max-http-header-size. I have found it here: Common application properties.

The default value for Tomcat and Jetty is 8KB and for Undertow is 1MB.

like image 39
rebeliagamer Avatar answered Oct 22 '22 01:10

rebeliagamer


In spring boot 1.3.5.RELEASE what worked for me is setting the following entry in application.properties:

server.tomcat.max-http-header-size=100000
like image 2
Shai Givati Avatar answered Oct 22 '22 01:10

Shai Givati