是 %20 和 + http url 中的内容相同吗?
我知道 %20 和 + 都解码为相同的二进制值(空格),并且对于大多数网络服务器,特别是那些映射到物理文件的网络服务器,它们将指向相同的资源。
但我的问题是,网址必须像 http://www.example.org/hello%20world 指向与 http://www.example.org/hello+world 相同的资源,它们在规范上是相同的吗?
在 HTTP/1.0 + 中没有映射到空格,所以我专门询问 HTTP/1.1。
I know that %20 and + both decode to the same binary value (a space), and for most webservers, especially those that map to physical files they will point to the same resource.
But my question is, must a url like http://www.example.org/hello%20world point to the same resource as http://www.example.org/hello+world, are they canonically the same?
In HTTP/1.0 + didn't map to a space, so I'm specifically asking about HTTP/1.1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅在查询字符串中:加号是保留字符,因此必须进行编码以在路径或查询字符串中传递实际的“+”。它用作空格的替代品是 W3C 建议,仅适用于查询细绳:
URI 比较(RFC 2616):
保留字符 (RFC 2396)
因此,在第三次复查时:没有任何官方声明它们是同一件事。从字面上使用“+”将
http://example.org/hello+world
定向到名为hello+world
的目录是不正确的,但没有任何说明应该这样做被视为等同于一个空格。Only within the query string: the plus sign is a reserved character, so must be encoded to pass an actual '+' in either the path or the query string. It's use as a substitute for spaces is a W3C Recommendation which only applies to the query string:
URI Comparison (RFC 2616):
Reserved characters (RFC 2396)
So, on the third go-around: there is nothing official that declares them to be the same thing. Using '+' literally to direct
http://example.org/hello+world
to a directory calledhello+world
is incorrect, but there's nothing that says it should instead be considered equivalent to a space.