SpringBoot项目报错:Error parsing HTTP request header Note: further occurrences of HTTP request parsing

SpirngBoot项目启动后没报错,但是用postman测试接口的时候发现会间歇式(一好一坏)出现错误:

Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens

单纯的出现也很正常,它却一次成功一次错误的,弄得我不知所措。

查阅网上资料,98%都说tomcat的header最大值配置更改就好了,但是springboot都是内置的tomcat,

修改的方法是:sever.tomcat.max-http-header-size=8192

但是这个配置已经被高版本的boot项目废掉了,

可以改为: sever.max-http-header-size=8192

满心欢喜,以为好了,然后发现并没有。

另外2%说可能和HTTPS协议有关,改为HTTP即可。

但是我这是本地启动的,一直都是HTTP。

纠结许久我发现罪魁祸首竟然是在请求的时候Header里面加上了Content-Length,并给了他定值,所以会报错。蠢哭~~

对于大家说的修改max-http-header-size的作用,我把这个设置为1,再次请求发现报的错和我这之前的并不一样,而是:

Error processing request
org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer.

猜你喜欢

转载自blog.csdn.net/A564492203/article/details/103730574