Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase header size limit Tomcat Java

Looking at https://tomcat.apache.org/tomcat-9.0-doc/config/http.html I see that 8KB is the default limit of Header Size in Tomcat Apache.

The log shows the following when I make a request with headers more than the default 8KB: Dec 30, 2019 1:59:26 PM org.apache.coyote.http11.Http11Processor service INFO: Error parsing HTTP request header Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Request header is too large at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:720) at org.apache.coyote.http11.Http11InputBuffer.parseHeader(Http11InputBuffer.java:867) at org.apache.coyote.http11.Http11InputBuffer.parseHeaders(Http11InputBuffer.java:563) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:311) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)

My Java Project does not have a server.xml inside /webapp/WEB-INF, just the web.xml. I tried to create a server.xml and add the following like said in this thread: <?xml version='1.0' encoding='utf-8'?> <Connector port="8080" protocol="HTTP/1.1" maxHttpHeaderSize="65536" maxPostSize="4194304" URIEncoding="UTF-8"/>//webapp/WEB-INF

How Can I increase the default size limit? I'd like to set 16KB.

Thanks in advance =)

PS: I am new in Tomcat/Java World, so sorry if I made a horrible mistake =p

like image 963
Bart Avatar asked May 18 '26 20:05

Bart


1 Answers

Edit Tomcat's server.xml and add maxHttpHeaderSize="65536":

<?xml version='1.0' encoding='utf-8'?>
<Connector 
        port="8080" 
        protocol="HTTP/1.1" 
        maxHttpHeaderSize="65536" 
        maxPostSize="4194304"
        URIEncoding="UTF-8"/>
like image 104
user20210336 Avatar answered May 21 '26 10:05

user20210336



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!