我想将tomcat 7配置为使用与默认CoyoteAdapter不同的适配器来处理某些格式错误的cookie。有可能吗?
原因是我们遇到了异常
SEVERE: Error processing request
java.lang.IllegalArgumentException: Control character in cookie value or attribute.
at org.apache.tomcat.util.http.CookieSupport.isHttpSeparator(CookieSupport.java:205)
at org.apache.tomcat.util.http.Cookies.getTokenEndPosition(Cookies.java:530)
at org.apache.tomcat.util.http.Cookies.processCookieHeader(Cookies.java:377)
at org.apache.tomcat.util.http.Cookies.processCookies(Cookies.java:195)
at org.apache.tomcat.util.http.Cookies.getCookieCount(Cookies.java:119)
at org.apache.catalina.connector.CoyoteAdapter.parseSessionCookiesId(CoyoteAdapter.java:1089)
at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:796)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:440)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1087)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:0)
除非您实现自己的org.apache.coyote.Processor
,否则您无法更改土狼适配器。但是在tomcat-8中,您可以更改cookie处理器:
org.apache.tomcat.util.http.CookieProcessor
lib
文件夹中<Context>
<CookieProcessor className="org.example.MonsterCookieProcessor"/>
<Context>
遗憾的是,您无法在tomcat-7中执行此操作,因为Cookie处理器逻辑已硬编码在CoyoteRequest
中:
private Cookies cookies = new Cookies(headers);