[英]How do I configure ANY web server to accept POST requests that have No Host and absolute request URIS?
I have a client that sends http requests with absolute request uris and does not define "host" 我有一个客户端发送带有绝对请求uri的http请求,并且未定义“主机”
There for a web server like Jetty rejects the POST request saying: 像Jetty这样的网络服务器拒绝POST请求,说:
org.eclipse.jetty.http.BadMessageException: 400: No Host org.eclipse.jetty.http.BadMessageException:400:无主机
Is there any way to configure jetty or any other web server to accept post requests that don't have a host? 有什么方法可以配置jetty或任何其他Web服务器来接受没有主机的发布请求?
https://tools.ietf.org/html/rfc7230#section-5.4 https://tools.ietf.org/html/rfc7230#section-5.4
A client MUST send a Host header for it to be compliant to HTTP/1.1 客户端必须发送主机标头以使其符合HTTP / 1.1
If you send an absolute URI in the target, then the Host
header must be the same as what is found in that absolute URI target. 如果在目标中发送绝对URI,则Host
标头必须与在该绝对URI目标中找到的相同。
Note that the HTTP/1.1 spec even states ... 请注意,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. 对于任何缺少主机头字段的HTTP / 1.1请求消息,以及包含多个主机头字段或具有无效字段值的主机头字段的任何请求消息,服务器必须以400(错误请求)状态码进行响应。
This makes it a requirement to respond with error 400 in this situation, always. 这就要求始终在这种情况下以错误400进行响应。
If you use HTTP/2, then you can avoid this because the split between target URI and Host header was addressed with the :authority
pseudo-header. 如果使用HTTP / 2,则可以避免这种情况,因为目标URI和主机标头之间的拆分是通过:authority
伪标头解决的。
See https://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2.3 参见https://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2.3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.