SpringBoot项目出现 A cookie header was received [***,***] that contained an invalid cookie. That cook..
o.apache.tomcat.util.http.parser.Cookie: A cookie header was received [1704716542,1704778481,1704890481] that contained an invalid cookie. That cookie will be ignored.
·
错误:
o.apache.tomcat.util.http.parser.Cookie : A cookie header was received [1704716542,1704778481,1704890481] that contained an invalid cookie. That cookie will be ignored.
Note: further occurrences of this error will be logged at DEBUG level.
原因
大致问题就是从Tomcat 8,Cookie的解析已经符合RFC 6265。由于RFC 6265不再接受以前允许的逗号分隔符(例如RFC 2109) "Cookie:KEY 1 = VAL 1,KEY 2 = VAL 2"的格式所以被视为非法。
解决办法
在启动类上加入以下代码:
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> cookieProcessorCustomizer() {
return tomcatServletWebServerFactory -> tomcatServletWebServerFactory.addContextCustomizers((TomcatContextCustomizer) context -> {
context.setCookieProcessor(new LegacyCookieProcessor());
});
}
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
已为社区贡献1条内容
所有评论(0)