如何增加标头大小限制Tomcat Java

时间:2019-12-30 14:49:40

标签: java http tomcat header

看看https://tomcat.apache.org/tomcat-9.0-doc/config/http.html,我发现Tomcat Apache中标头大小的默认限制是8KB。

当我发出的标头超过默认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)

我的Java项目在server.xml中没有/webapp/WEB-INF,只有web.xml。我尝试创建一个server.xml并添加以下内容,例如在此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

如何增加默认大小限制?我想设置16KB。

预先感谢=)

PS:我是Tomcat / Java World的新手,对不起,如果我犯了一个可怕的错误= p

1 个答案:

答案 0 :(得分:1)

看着API doc似乎是这个

sed -i%TEMP%\* "s/regexp/replacement/g" *.txt

可能是有效的解决方案。