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).
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..
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.
With Spring Boot 2.4 in application.properties
:
server.max-http-header-size=10MB
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