简体   繁体   English

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

[英]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.

相关问题 如何配置Cassini Web服务器以接受对不同主机的请求? - How can I configure Cassini web server to accept requests to different hosts? 如何从主机将Web服务部署到虚拟服务器? - How do I deploy a web service to a virtual server from the host? 如何配置C#Web服务客户端以并行发送HTTP请求标头和正文? - How do I configure a C# web service client to send HTTP request header and body in parallel? 如何将请求发布到此SOAP Web服务 - How do POST a Request to this SOAP Web Service 如何配置WebServiceTemplate在HTTPS下将肥皂请求发送到服务器? - How do I configure WebServiceTemplate to send soap request to Server under HTTPS? 如何配置IIS 7以允许从ISAPI Web服务器中进行远程数据库连接 - How do I configure IIS 7 to allow a remote database connection from within an ISAPI Web Server 如何检查POST请求是否以JSON Web服务发送到服务器 - How to check POST Request is sended to Server in JSON web service 如何向GAE REST服务器授权请求? - How do I authorise requests to my GAE REST server? 如何在云服务器中托管Web服务? - How to host the web service in cloud server? 如何在Web服务客户端请求中配置SOAP XML名称空间? - How can I configure SOAP XML namespaces in web service client request?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM