问题Invalid character found in the request target. The valid characters are defined in RFC 7230 and (代

Posted windbag7

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了问题Invalid character found in the request target. The valid characters are defined in RFC 7230 and (代相关的知识,希望对你有一定的参考价值。

具体来说,就是添加了些规则去限制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=|{}

重启tomcat即可

以上是关于问题Invalid character found in the request target. The valid characters are defined in RFC 7230 and (代的主要内容,如果未能解决你的问题,请参考以下文章

问题Invalid character found in the request target. The valid characters are defined in RFC 7230 and (代

Springboot 报错 Invalid character found in the request target. The valid characters are defined in RFC

异常:Invalid character found in the request target. The valid characters are defined in RFC 3986

java.lang.IllegalArgumentException: Invalid character found in the request target.

后台报错java.lang.IllegalArgumentException: Invalid character found in the request target.

Tomcat 8 Invalid character found in the request target. The valid characters are defined in RFC 3986