gpt4 book ai didi

debugging - 为什么tomcat在使用类似于 "400 Bad Request"的url时返回 "something.com-xyz"

转载 作者:行者123 更新时间:2023-11-28 22:47:27 35 4
gpt4 key购买 nike

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

为了测试目的,假设我们在主机文件中有以下条目

127.0.0.1 hello.hello.hello-erq

然后我们尝试从 curl 访问这个 url

curl -v hello.hello.hello-er: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 中使用 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>

两个测试的所有 tomcat 配置都是相同的,同样的问题也在开箱即用的 tomcat 服务器上复制。

我试图在 tomcat-8 上复制同样的问题,但两个 url 在那里都工作正常。我如何才能更深入地挖掘并找出 7.0.88 中此问题的根本原因?

是否有一些我可以启用的额外日志记录以获取有关此问题的更多信息?

或者我唯一剩下的就是拉扯我的头发并升级?

最佳答案

Tomcat 正在尝试 enforce the domain name specification通过在 TLD 中使用连字符拒绝您的主机名。这被认为是 Tomcat 中的错误,并且 fixed in 7.0.89 (and versions of Tomcat 8.0.x, 8.5.x and 9.0.x released around the same time) .

所以看起来你只需要一个小的版本bump。

关于debugging - 为什么tomcat在使用类似于 "400 Bad Request"的url时返回 "something.com-xyz",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53875350/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com