springboot2.x设置请求头大小

springboot2.x设置请求头大小,第1张

项目测试环境今天出现一个奇怪的现象,一个超管用户,多分配了一个角色后,所有请求就报400,去掉对应的角色就可以

一开始没有想到怎么处理,因为虽然前端报错,但是错误日志没有任何错误

下午静下来想了想,可能跟请求头有关,之前遇到过因为请求头过大导致400,这次和之前基本一样的场景:因为用户多了个角色,用户信息就多了一些内容,用户信息是base64加密后放到请求头中,经测试,改大请求头,给用户分配角色后一切正常,问题解决

接下来处理为什么报400但是却没有报错日志

后继续排查其实系统请求响应有报错:

HTTP Status 400 – Bad RequestHTTP Status 400 – Bad Request


Type Exception Report

Message Request header is too large

Description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

Exception

java.lang.IllegalArgumentException: Request header is too large
    org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:781)
    org.apache.coyote.http11.Http11InputBuffer.parseHeader(Http11InputBuffer.java:942)
    org.apache.coyote.http11.Http11InputBuffer.parseHeaders(Http11InputBuffer.java:593)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:284)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:750)

Note The full stack trace of the root cause is available in the server logs.


Apache Tomcat/9.0.39

修改header配置(100k)

server:

max-http-header-size: 102400

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/756160.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-30
下一篇 2022-04-30

发表评论

登录后才能评论

评论列表(0条)

保存