Debugging 为什么tomcat会返回;“400错误请求”;在使用类似于“url”的url时;something.com xyz“;

Debugging 为什么tomcat会返回;“400错误请求”;在使用类似于“url”的url时;something.com xyz“;,debugging,tomcat,tomcat7,Debugging,Tomcat,Tomcat7,如果主机名以xyx.com-abc结尾,为什么Tomcat 7.0.88版会给出“400错误请求”错误代码 出于测试目的,我们假设hosts文件中有以下条目 127.0.0.1 hello.hello.hello-erq 我们尝试从curl访问这个url curl-v你好。你好。你好,呃:8080 我们得到以下输出 * Rebuilt URL to: hello.hello.hello-er:8080/ * Trying 127.0.0.1... * Connected to hello.h

如果主机名以xyx.com-abc结尾,为什么Tomcat 7.0.88版会给出“400错误请求”错误代码

出于测试目的,我们假设hosts文件中有以下条目

127.0.0.1 hello.hello.hello-erq

我们尝试从curl访问这个url

curl-v你好。你好。你好,呃:8080

我们得到以下输出

* Rebuilt URL to: hello.hello.hello-er:8080/
*   Trying 127.0.0.1...
* Connected to hello.hello.hello-er (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: hello.hello.hello-er:8080
> User-Agent: curl/7.49.0
> Accept: */*
>
< HTTP/1.1 400 Bad Request
< Server: Apache-Coyote/1.1
< Transfer-Encoding: chunked
< Date: Thu, 20 Dec 2018 19:53:09 GMT
< Connection: close
<
* Closing connection 0
*重建的URL地址:hello.hello.hello er:8080/
*正在尝试127.0.0.1。。。
*已连接到hello.hello.hello-er(127.0.0.1)端口8080(#0)
>GET/HTTP/1.1
>主持人:你好。你好。你好。呃:8080
>用户代理:curl/7.49.0
>接受:*/*
>
在url中使用localhost时,我们得到

 C:\playground\apache-tomcat-7.0.88-windows-x64\apache-tomcat-7.0.88\bin>curl -v localhost:8080
* Rebuilt URL to: localhost:8080/
*   Trying ::1...
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.49.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: text/html;charset=ISO-8859-1
< Transfer-Encoding: chunked
< Date: Thu, 20 Dec 2018 20:00:07 GMT
<

<!DOCTYPE html>
C:\playdy\apache-tomcat-7.0.88-windows-x64\apache-tomcat-7.0.88\bin>curl-v localhost:8080
*重建的URL到:localhost:8080/
*正在尝试::1。。。
*正在尝试127.0.0.1。。。
*已连接到本地主机(127.0.0.1)端口8080(#0)
>GET/HTTP/1.1
>主机:本地主机:8080
>用户代理:curl/7.49.0
>接受:*/*
>
所有的tomcat配置对于这两个测试都是相同的,同样的问题也在一个普通的开箱即用的tomcat服务器上复制

我试图在tomcat-8上复制相同的问题,但两个url在那里都运行良好。如何在7.0.88中深入挖掘并找出此问题的根本原因

是否有一些额外的日志记录,我可以使更多关于这个问题

或者我唯一剩下的就是拔头发升级了

Tomcat试图通过在TLD中使用连字符拒绝您的主机名来删除您的主机名。这被认为是Tomcat和中的一个bug


因此,您似乎只需要一个小版本的bump。

您可以通过编辑conf/loggin.properties添加非常精细的loggin。