JAVA -tomcat- Request header is too large

We Are Going To Discuss About JAVA -tomcat- Request header is too large. So lets Start this Java Article.

JAVA -tomcat- Request header is too large

  1. JAVA -tomcat- Request header is too large

    The maximum size of the request and response HTTP header, specified in
    bytes. If not specified, this attribute is set to 4096 (4 KB).

  2. JAVA -tomcat- Request header is too large

    The maximum size of the request and response HTTP header, specified in
    bytes. If not specified, this attribute is set to 4096 (4 KB).

Solution 1

here is the question, is there any limit in HTTP headers? The Answer is No.
there is no limit but web-servers are limiting their incoming request header size even in POST requests therefore we getting 413 (Request header is too large). This limitation is including request line and header fields.

http://httpd.apache.org/docs/2.2/mod/core.html#limitrequestfieldsize

https://tomcat.apache.org/tomcat-5.5-doc/config/http.html

http://nginx.org/en/docs/http/ngx_http_core_module.html#large_client_header_buffers

Maximum on http header values?


In my case, I had SpringBoot 1.5.8 and used HTTP POST, however I had to add:

server.max-http-header-size=10000000 

in application.properties.

Original Author Jay Of This Content

Solution 2

Solved!
I was using HTTP GET instead of HTTP POST.
Technically I have seen HttpGet will have issue if the URL length goes beyond 2000 characters. In that case, it’s better to use HttpPost or split the URL.
Browsers have limits ranging on the 2kb – 8kb

Tomcat: Request header Too large

Original Author Sarthak Srivastava Of This Content

Solution 3

The maximum size of the request and response HTTP header, specified in
bytes. If not specified, this attribute is set to 4096 (4 KB).

To avoid getting Error parsing HTTP request header error you can increase the following value by doing this.

Go to following location: $TOMCAT_HOME/conf/server.xml

In server.xml change the HTTP/1.1 Connector entry and set the maxHttpHeaderSize to “65536” (64Kb in bytes) as shown below:

<Connector port="8080" maxHttpHeaderSize="65536" protocol="HTTP/1.1" ... />

Or

You can use the POST method it can carry upto 2 megabytes according to Tomcat.

The maximum size in bytes of the POST which will be handled by the
container FORM URL parameter parsing. The limit can be disabled by
setting this attribute to a value less than or equal to 0. If not
specified, this attribute is set to 2097152 (2 megabytes).

Hope this information would help you..

Original Author Dulacoste Of This Content

Solution 4

With Spring Boot 2.4 in application.properties:

server.max-http-header-size=10MB

Original Author Markus Pscheidt Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment