我有一个应用程序向微服务发送请求。在标题中有JWT令牌变大了,我收到此错误
Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Message</b> Request header is too large</p><p><b>Description</b> 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).</p><p><b>Exception</b></p><pre>java.lang.IllegalArgumentException: Request header is too large
我发现您可以在 yml 配置文件中增加标头的最大允许大小
server:
max-http-header-size: 5MB
但我仍然得到相同的结果。我正在使用 Spring 2.2.6
尝试更改
服务器: 最大 http-header-size: 5MB
自:
服务器: 最大 servlet-header-size: 5MB
"http"用于Spring boot 1.4.x和1.5.x,而2.x使用"servlet"关键字
我有同样的问题: spring.servlet.multipart.max-file-size=512KB 不得不更改为 spring.http.multipart.max-file-size=512KB 但是我的应用程序正在使用 spring.boot.1.5.4
对于 YML 格式,请查看这篇文章 https://stackoverflow.com/a/54302823/10315229
> https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/html/common-application-properties.html:
HTTP 消息标头的最大大小(以字节为单位(
在代码 (https://github.com/spring-projects/spring-boot/pull/5641/files( 中:
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
public class ServerProperties
...
/**
* Maximum size in bytes of the HTTP message header.
*/
private int maxHttpHeaderSize = 0; // bytes
因此,5M
值很可能会转换为5
,而不是5242880
字节(5 兆字节(。