Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The valid characters are defined in RFC 7230 and RFC 3986

Tags:

java

tomcat8

My program throws this exception online,I know the reason why it is wrong. My question is how do I find the wrong place,The Java cannot catch the location of this exception. How do I get additional information about this exception,For example, the API for this error requested address.

The error message is as follows:

2019-01-18  07:49:23.076 [http-nio-127.0.0.1-8081-exec-96] INFO  org.apache.coyote.http11.Http11Processor - Error parsing HTTP request header
 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 3986
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:484)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:684)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
like image 778
Leandy Avatar asked Jan 21 '19 10:01

Leandy


2 Answers

If you use an upper version of Tomcat 8.5 it throws this exception if the URL path contains '[' and ']'. For older versions, it works.

like image 103
Dani Avatar answered Sep 22 '22 06:09

Dani


The workaround would be adding below attributes to http connector port in tomcat server.xml file

relaxedPathChars="[]|" relaxedQueryChars="[]|{}^\`"<>"
like image 39
Sreekanth Kategaru Avatar answered Sep 18 '22 06:09

Sreekanth Kategaru