之前见过Request header is too large没记录下来,碰巧见到这个下面这个文章,正好看看对应的源码类。
https://mp.weixin.qq.com/s/wkH_e9d4U4b0vSX_WuJyYg
SpringBoot Request header is too large 的问题解决
Request header is too large指的是请求头超过了tomcat的限值,在tomcat的org.apache.coyote.http11.AbstractHttp11Protocol类中定义了其默认值:
当请求头大于 8192(即8 * 1024),就会报错。针对这样的大数据量的请求,需要单独配置这个maxHttpHeaderSize的值。
处理方案:
1、修改tomcat配置文件
在tomcat安装目录/config/server.xml文件的Connector配置中增加参数:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" maxPostSize="51200" maxHttpHeaderSize ="102400"/>
2、Springboot中修改application.yml
server:
tomcat:
max-http-form-post-size: 50MB
max-http-header-size: 102400
threads:
max: 1000
max-connections: 6000