【问题标题】:Query String to identify a resource查询字符串以识别资源
【发布时间】:2018-11-29 13:20:32
【问题描述】:

在 HTTP 协议中,URI 用于标识资源,查询字符串表示额外的参数,根据msdn

在将资源返回给用户之前,Web 服务器可以使用这些参数来做一些额外的事情。

我的问题是从 HTTP 中介的角度来看,两个相似的 URI,仅在查询字符串中区分,标识两个不同的资源吗?

【问题讨论】:

  • 你不能对带有查询字符串的 URI 做任何假设,这就是为什么浏览器通常不会缓存它们的原因。
  • 感谢您的帮助。

标签: http uri query-string


【解决方案1】:

在查询组件中不同的 HTTP URI 是不等价的(除非唯一的区别是 percent-encoding of unreserved characters)。它们仍然可以识别相同的资源,但这与确定它们在 URI 标准眼中是否等效无关。

URI 标准(STD 66;当前:RFC 3986)解释了如何检查 URI 是否等效:
Normalization and Comparison

示例

这些 URI 是等效的:

http://example.com/foo?bar
http://example.com/foo?ba%72
http://example.com:80/foo?bar

这些 URI 不等价:

http://example.com/foo?bar
http://example.com/foo?baz

这些都不是等价的 (details):

http://example.com/foo
http://example.com/foo?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-18
    • 1970-01-01
    • 1970-01-01
    • 2012-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    相关资源
    最近更新 更多