【Tomcat】Invalid character found in the request target
Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
Tomcat接收到的请求的URI中包含了不合法的字符,比如 { } ( ) ^ ` \ | # \\ 这些字符在RFC (Request Format Comment)文档中有规定,不能被用在Request Header,也就是request的URI中。
查看tomcat源码
apache-tomcat-7.0.73-src\java\org\apache\coyote\http11\InternalInputBuffer.java
public class InternalInputBuffer extends AbstractInputBuffer<Socket> {
....省略
/**
* Read the request line. This function is meant to be used during the
* HTTP request header parsing. Do NOT attempt to read the request body
* using it.
*
* @throws IOException If an exception occurs during the underlying socket
* read operations, or if the given buffer is not big enough to accommodate
* the whole line.
*/
@Override
public boolean parseRequestLine(boolean useAvailableDataOnly)
throws IOException {
...省略
//
// Reading the URI
//
boolean eol = false;
while (!space) {
// Read new bytes if needed
if (pos >= lastValid) {
if (!fill())
throw new EOFException(sm.getString("iib.eof.error"));
}
// Spec says single SP but it also says be tolerant of HT
if (buf[pos] == Constants.SP || buf[pos] == Constants.HT) {
space = true;
end = pos;
}else if (HttpParser.isNotRequestTarget(buf[pos])) {
//如果请求参数中的字符不是被允许的字符,则抛异常 HttpParser这个类 看下面代码片
throw new IllegalArgumentException(sm.getString("iib.invalidRequestTarget"));
}
pos++;
}
... 省略
return true;
}
}
apache-tomcat-7.0.73-src\java\org\apache\tomcat\util\http\parser\HttpParser.java
private static final int ARRAY_SIZE = 128;
private static final boolean[] IS_NOT_REQUEST_TARGET = new boolean[ARRAY_SIZE];
static { // Digest field types.for (int i = 0; i < ARRAY_SIZE; i++) { // Control> 0-31, 127 if (i < 32 || i == 127) { IS_CONTROL[i] = true; }// Not valid for request target. // Combination of multiple rules from RFC7230 and RFC 3986. Must be // ASCII, no controls plus a few additional characters excluded // 不合法的字符在这里都会导致请求不合法而抛异常 请求失败 if (IS_CONTROL[i] || i > 127 || i == ' ' || i == '\"' || i == '#' || i == '<' || i == '>' || i == '\\' || i == '^' || i == '`' || i == '{' || i == '|' || i == '}') { IS_NOT_REQUEST_TARGET[i] = true; } } }
HTTP协议说到底只是一个OSI应用层通讯的标准,在tomcat源码中对HTTP进行了实现,可能在一些Tomcat版本中没有实现对请求字符的限制,可以预见,在Tomcat7.0.64之后的版本以及 Tomcat8、9都会对请求头的字符进行限制。
【Tomcat】Invalid character found in the request target的更多相关文章
- Tomcat 8 Invalid character found in the request target. The valid characters are defined in RFC 3986
终极解决方案: Invalid character found in the request target. The valid characters are defined in RFC 3986 ...
- Tomcat v7.0 java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
十二月 , :: 下午 org.apache.coyote.http11.AbstractHttp11Processor process 信息: Error parsing HTTP request ...
- Tomcat : Invalid character found in the request target
Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC ...
- tomcat Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
1.情景展示 tomcat 日志时不时会报出如下异常信息,到底是怎么回事? java.lang.IllegalArgumentException: Invalid character found ...
- Tomcat报错Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
问题描述:后台报错 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.java ...
- Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC
解决Invalid character found in the request target. The valid characters are defined in RFC 7230 and RF ...
- Invalid character found in the request target.
背景:springboot项目内置tomcat9.0 调用的接口中有{}就会报错 解决办法: 新的tomcat新版本增加了一个新特性,就是严格按照 RFC 3986规范进行访问解析,而 RFC 398 ...
- 后台报错java.lang.IllegalArgumentException: Invalid character found in the request target.
报错: Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. java.lang ...
- 解决springboot项目请求出现非法字符问题 java.lang.IllegalArgumentException:Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
springboot版本: 2.1.5 最近使用springboot搭建了一个App后台服务的项目,开发接口的时候在本机使用postman工具做请求测试,请求返回一直很正常,但是在前端开发使用h5请求 ...
随机推荐
- C# 中的 ConfigurationManager类引用方法应用程序配置文件App.config的写法
c#添加了Configuration;后,竟然找不到 ConfigurationManager 这个类,后来才发现:虽然引用了using System.Configuration;这个包,但是还是不行 ...
- Luogu 1111 修复公路(最小生成树)
Luogu 1111 修复公路(最小生成树) Description A地区在地震过后,连接所有村庄的公路都造成了损坏而无法通车.政府派人修复这些公路. 给出A地区的村庄数N,和公路数M,公路是双向的 ...
- 二叉树 java实现
class Node { private int data; // 其他数据 private int otherData; private Node left; private Node right; ...
- JAVA高并发
一.JAVA高级并发 1.5JDK之后引入高级并发特性,大多数的特性在java.util.concurrent 包中,是专门用于多线程发编程的,充分利用了现代多处理器和多核心系统的功能以编写大规模并发 ...
- 关于position:fixed;的居中问题
通常情况下,我们通过操作margin来控制元素居中,代码如下: #name{ maigin:0px auto; } 但当我们把position设置为fixed时,例如: #id{ position:f ...
- SQL注入的各种类型的检测方式
#SQL注入各个类型检测方式 http://127.0.0.1/day6/1.php?id=1 union select 1,name,pass from admin 数字型 数字型不用特意加字符,直 ...
- 抓取60000+QQ空间说说做一次数据分析
对于QQ空间的数据一直来是垂涎不已,老早就想偷过来研究研究,这几天闲下来便开始动手... 整个程序的流程为:登录-->获取cookie-->获取所有的好友qq_number-->根据 ...
- ECMAScript6新特性之let、const
第一次在博客园写博客,想把自己每一天学习到的知识点记录下来,心里有点紧张(PS:不知道自己能不能写好......嘿嘿).言归正传,咱们先来说说"ECMAScript"这到底是啥玩意 ...
- Swift学习之元组(Tuple)
定义 元组是由若干个类型的数据组成,组成元组的数据叫做元素,每个元素的类型都可以是任意的. 用法一 let tuples1 = ("Hello", "World" ...
- ubuntu中ssh自启动
打开/etc/rc.local文件,在exit 0语句前加入: /etc/init.d/ssh start(前提是本身的启动方法是这样的才可以) 或者/usr/local/sbin/sshd(我使用的 ...