如何在 HTTP1.1 中进行标准的符合 GET 查询
简而言之:如何以符合 rfc2616 的 HTTP1.1 标准的方式对 http://example 这样的 URL 进行 GET 查询.com/?query
维基百科说
GET /?query HTTP/1.1
...
在 rfc2616它说
Request-URI = "*" | absoluteURI | abs_path | authority
只有abs_path和absoluteURI与GET请求相关。
其中abs_path
实际上来自uri rfc,它禁止“? ”,因为 abs_path 实际上是 uri 中位于查询部分之前的部分。所以看来维基百科的变体在语法上是不正确的。
AbsoluteURI
对于这一点,uri rfc 说,
absoluteURI = scheme ":" ( hier_part | opaque_part )
hier_part = ( net_path | abs_path ) [ "?" query ]
因此可以将这样的查询放入请求 URI 中,但不幸的是,rfc2616 不允许为不与代理通信的客户端传输绝对URI。网络服务器可以以符合标准的方式接收此信息,但实际上不可能使用浏览器或其他客户端以符合标准的方式发送它。
rel_path
令我惊讶的是 rfc2616 提到了一个“?”在 rel_path 中,但 rfc2396 也不允许这样做实际上可以将 rel_path 放入 http 请求中,因为 rel_path 规则在 rfc2616 中的任何地方都没有语法使用。
所以我的问题是,如何符合标准地提出这样的请求,并且所有浏览器都违反了标准吗?
In shord: How is in a HTTP1.1 standard conformant way to rfc2616 a GET query to an URL like http://example.com/?query
Wikipedia says
GET /?query HTTP/1.1
...
In the rfc2616 it says
Request-URI = "*" | absoluteURI | abs_path | authority
Only abs_path and absoluteURI are relevant for GET requests.
abs_path
where abs_path is actually from the uri rfc which forbids a "?", since the abs_path is actually the part of the uri which comes before the query part. So it seems the variant from wikipedia is syntacticly incorrect.
absoluteURI
For this the uri rfc says
absoluteURI = scheme ":" ( hier_part | opaque_part )
hier_part = ( net_path | abs_path ) [ "?" query ]
So it is possible to put such a query into the Request-URI, but unfortunetly the rfc2616 dissallows the transmission of absoluteURI for client not speaking with a proxy. It is possible to receive this in a standard compliant way by a webserver, but it is actually not possible to send it standard compliently with a browser or some other client.
rel_path
To my astonishment the rfc2616 mentions a "?" in the rel_path, but neither is this allowed by rfc2396, nor is it actually possible to put a rel_path somewhere into an http request, since the rel_path rule is not syntacticly used anywhere in rfc2616.
So my question is, how to standard compliantly make such an request, and are all the browsers breaking the standard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 RFC 2616 中的错误。请参阅 http://trac.tools.ietf .org/wg/httpbis/trac/ticket/11。
That's a bug in RFC 2616. See http://trac.tools.ietf.org/wg/httpbis/trac/ticket/11.