Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA -tomcat- Request header is too large

INFO: Error parsing HTTP request header  Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Request header is too large     at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:512)     at org.apache.coyote.http11.InternalInputBuffer.fill(InternalInputBuffer.java:501)     at org.apache.coyote.http11.InternalInputBuffer.parseRequestLine(InternalInputBuffer.java:171)     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:996)     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)     at java.lang.Thread.run(Thread.java:722 

How could I solve this in my spring web application?

I had gone through this thread Request header is too large

like image 688
Sarthak Srivastava Avatar asked Sep 27 '16 09:09

Sarthak Srivastava


People also ask

How do I fix the request header size is too long?

The “Bad Request – Request Too Long” error is exclusive to browsers. The typical solution is to clear the cache and cookies in your browser.

How do I fix bad request request too long HTTP Error 400 size the request headers is too long?

The “Bad Request – Request Too Long” error is exclusive to Chrome. Typically the solution is to clear the cache and cookies in your Chrome browser, making sure to completely close all browser windows and tabs after doing so.

What does request header field too large mean?

The HTTP 431 Request Header Fields Too Large response status code indicates that the server refuses to process the request because the request's HTTP headers are too long. The request may be resubmitted after reducing the size of the request headers.

How do I request a header size?

go to the network tab and right click the first item and click copy as cURL (this is how you will get the header size. Then go to terminal and do your curl command curl ... -w '%{size_request} %{size_upload}' which will print out the request size at the end.


2 Answers

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.

like image 58
Jay Avatar answered Oct 05 '22 15:10

Jay


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

like image 25
Sarthak Srivastava Avatar answered Oct 05 '22 17:10

Sarthak Srivastava