Request header is too large 的问题解决

1:问题原因:

后台接受前台传入的内容字符串,由于内容字符串太大,导致打印台报错.

1-1:错误描述:

java.lang.IllegalArgumentException: Request header is too large
    at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:701)
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:455)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:667)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:798)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1434)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)


1-2:解决方案(服务器容器:tomcat):

1:请求头超过了tomcat的限值。本来post请求是没有参数大小限制,但是服务器有自己的默认大小。
2:配置 tomcat的server.xml文件,增加请求字段长度


增加maxHttpHeaderSize参数配置,当maxPostSize=0时,表示不限制.

1-3:SpringBoot项目:

在application.yml文件中,配置server.max-http-header-size=102400参数,即可改变内嵌tomcat容器的最大头大小.

1-4:详细错误原因:

在tomcat的org.apache.coyote.http11.AbstractHttp11Protocol类中定义了其默认值:

    /**
     * Maximum size of the HTTP message header.
     */
    private int maxHttpHeaderSize = 8 * 1024;
    //所以当请求头大于8*1024时,就会报错.增对大数据量的请求,需要单独配置maxHttpHeaderSize参数属性.

你可能感兴趣的:(编程语言,tomcat,http,springboot)