Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Tomcat error resolution-The valid characters are defined in RFC 7230 and RFC 3986

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report