Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986at org.apache.coyote.http11.InternalNioInputBuffer.parseRequestLine(InternalNioInputBuffer.java:317)at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1028)at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1770)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1729)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Thread.java:745) 1. 问题可能是因为tomcat配置的缓冲区大小不够, 修改tomcat/conf/server.xml文件. <Connector port="8080" executor="tomcatThreadPool" protocol="HTTP/1.1" maxThreads="1000" maxHttpHeaderSize="8192" minSpareThreads="100" maxSpareThreads="200" acceptCount="1000" maxConnections="1000" connectionTimeout="30000" keepAliveTimeout="15000" maxKeepAliveRequests="1" tcpNoDelay="true" redirectPort="8443" enableLookups="false" URIEncoding="UTF-8"/> 2. 查看你的请求是否是POST请求, 如果是GET请求方式, 请修改成POST测试; 3. 修改tomcat/conf/catalina.properties的配置文件 Tomcat在 7.0.73, 8.0.39, 8.5.7 版本后,添加了对于http头的验证。 具体来说,就是添加了些规则去限制HTTP头的规范性 org.apache.tomcat.util.http.parser.HttpParser#IS_NOT_REQUEST_TARGET[]中定义了一堆not request target if(IS_CONTROL[i] || i > 127 || i == 32 || i == 34 || i == 35 || i == 60 || i == 62 || i == 92 || i == 94 || i == 96 || i == 123 || i == 124 || i == 125) { IS_NOT_REQUEST_TARGET[i] = true; } 转换过来就是以下字符(对应10进制ASCII看): 键盘上那些控制键:(<32或者=127) 非英文字符(>127) 空格(32) 双引号(34) #(35) <(60) >(62) 反斜杠(92) ^(94) TAB上面那个键,我也不晓得嫩个读(96) {(123) }(124) |(125) 解决办法: 配置tomcat的catalina.properties 添加或者修改: tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}
java.lang.IllegalArgumentException: Invalid character found in the request target.
最新推荐文章于 2024-06-21 14:46:41 发布