是 %20 和 + http url 中的内容相同吗?

发布于 2024-09-28 05:25:47 字数 376 浏览 3 评论 0原文

我知道 %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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半世蒼涼 2024-10-05 05:25:47

仅在查询字符串中:加号是保留字符,因此必须进行编码以在路径或查询字符串中传递实际的“+”。它用作空格的替代品是 W3C 建议,仅适用于查询细绳:

在查询字符串中,加号
保留作为简写符号
一个空间。因此,实数加号
必须被编码。这个方法被使用了
使查询 URI 更容易传入
不允许空格的系统。

URI 比较(RFC 2616):

比较两个 URI 以确定是否
它们匹配与否,客户端应该使用
区分大小写的逐个八位位组
比较整个 URI,
这些例外:

 - 空或未给出的端口相当于默认端口
    该 URI 引用的端口;

    - 主机名的比较必须不区分大小写;

    - 方案名称的比较必须不区分大小写;

    - 空的abs_path相当于abs_path“/”。

除上述字符外的字符
“保留”和“不安全”集(参见 RFC
2396 [42])相当于他们
“%”HEX HEX”编码。

保留字符 (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:

Within the query string, the plus sign
is reserved as shorthand notation for
a space. Therefore, real plus signs
must be encoded. This method was used
to make query URIs easier to pass in
systems which did not allow spaces.

URI Comparison (RFC 2616):

When comparing two URIs to decide if
they match or not, a client SHOULD use
a case-sensitive octet-by-octet
comparison of the entire URIs, with
these exceptions:

  - A port that is empty or not given is equivalent to the default
    port for that URI-reference;

    - Comparisons of host names MUST be case-insensitive;

    - Comparisons of scheme names MUST be case-insensitive;

    - An empty abs_path is equivalent to an abs_path of "/".

Characters other than those in the
"reserved" and "unsafe" sets (see RFC
2396 [42]) are equivalent to their
""%" HEX HEX" encoding.

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 called hello+world is incorrect, but there's nothing that says it should instead be considered equivalent to a space.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文