Tomcat error resolution-The valid characters are defined in RFC 7230 and RFC 3986
This article introduces the relevant knowledge of "Tomcat error resolution-The valid characters are defined in RFC 7230 and RFC 3986". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
My problem interface is that the interface contains a "^" special symbol. Tomcat 8.5.35 reports the following error.
Invalid character found in the request target. The valid characters are defined in RFC 3986
See Error parsing HTTP request header from the error log
The person responsible for parsing the http request is org.apache.tomcat.util.http.parser.HttpParser, which limits the characters in URL for the request. The specific code is as follows:
A bunch of not request target is defined in IS_NOT_REQUEST_TARGET []
If (IS_ control [I] | | 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;}
This translates to the following characters (corresponding to decimal ASCII), that is, special characters that cannot be included in URL:
Those control keys on the keyboard: (127)
Space (32)
Double quotation marks (34)
# (35)
(62)
Backslash (92)
^ (94)
The key above TAB, ~ (96)
{(123)
} (124)
| (125)
After doing it myself for a long time, all baidu got was like this:
Add 2 lines at the end of the conf/catalina.properties:
Tomcat.util.http.parser.HttpParser.requestTargetAllow= | {} org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
That's how I added it.
Tomcat.util.http.parser.HttpParser.requestTargetAllow= | {} ^ org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true
But my problem is still unsolved. I found these things by looking at the documents:
That is to say, this configuration can only handle the accepted characters as {} |, crying.
Document address: https://tomcat.apache.org/tomcat-8.5-doc/config/systemprops.html
While hesitating to lower the version to yield, I searched the document for the "^" symbol and found this. So
Document address: https://tomcat.apache.org/tomcat-8.5-doc/config/http.html
In the node in conf/server.xml, add 2 attributes:
RelaxedPathChars= "| {} [] ^," relaxedQueryChars= "| {} [] ^,"
Solve the problem perfectly!
This is the end of the content of "Tomcat error Resolution-The valid characters are defined in RFC 7230 and RFC 3986". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!