如何配置任何 Web 服务器以接受 POST 没有主机和绝对请求 URIS 的请求?

How do I configure ANY web server to accept POST requests that have No Host and absolute request URIS?

我有一个客户端发送带有绝对请求 uris 的 http 请求并且没有定义 "host"

像 Jetty 这样的 Web 服务器拒绝 POST 请求说:

org.eclipse.jetty.http.BadMessageException: 400: No Host

有没有办法配置码头或任何其他网络服务器以接受 post 没有主机的请求?

https://www.rfc-editor.org/rfc/rfc7230#section-5.4

客户端必须发送主机 header 以使其符合 HTTP/1.1

如果您在目标中发送绝对 URI,则 Host header 必须与在该绝对 URI 目标中找到的内容相同。

请注意 HTTP/1.1 规范甚至声明 ...

A server MUST respond with a 400 (Bad Request) status code to any HTTP/1.1 request message that lacks a Host header field and to any request message that contains more than one Host header field or a Host header field with an invalid field-value.

这就要求在这种情况下始终以错误 400 响应。

如果您使用 HTTP/2,则可以避免这种情况,因为目标 URI 和主机 header 之间的拆分已通过 :authority pseudo-header.[=15 解决=]

https://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2.3