URL 路径段中的参数

Parameters in Path Segments of URL

URL格式有一件有趣的事:
URL.

路径段中的参数

有关详细信息,请参阅
中的“2.2.5”部分 “O'Reilly - HTTP - 权威指南”。

这本书可以在 Internet 上免费找到。

或者在官方规范中 https://www.ietf.org/rfc/rfc2396.txt 第 3.3 节

3.3. Path Component

The path component contains data, specific to the authority (or the scheme if there is no authority component), identifying the resource
within the scope of that scheme and authority.

  path          = [ abs_path | opaque_part ]

  path_segments = segment *( "/" segment )
  segment       = *pchar *( ";" param )
  param         = *pchar

  pchar         = unreserved | escaped |
                  ":" | "@" | "&" | "=" | "+" | "$" | ","

让我们考虑以下 URL:

http://www.example.com/first-segment/second-segment/index.html?type=HelloWorld

这里/first-segment/second-segment/index.html是URL的Path部分。

  1. 并且first-segment是该路径的第一段
  2. second-segment 是该路径的第二段
  3. index.html 是该路径的第三段

那本书中说每个段可以有单独的参数,用分号“;”分隔。在我们的示例中,它可能是:

http://www.example.com/first-segment;f1=WWW/second-segment;s1=1;s2=2/index.html;i1=100;abc=200?type=HelloWorld
  1. 此处 f1 - first-segment
  2. 的参数
  3. s1s2 - second-segment
  4. 的参数
  5. i1abc 参数 index.html

问题是:您知道 URL 中此类参数的任何实际示例吗?

我不知道路径段中确切参数的任何示例。

但最接近的例子是连接和 SFTP 参数(已过期)SFTP URL proposal

有人提议 connection parameter,SSH 主机密钥指纹 fingerprint

sftp://username:password;fingerprint=ssh-dss-0b-77-...@example.com/

有人提出 SFTP parametertypecode 用于传输模式(ascii 与二进制)。没有官方的例子,但应该是这样的:

sftp://username:password@example.com/path/file;typecode=i

(实际上,虽然在语义上有所不同,但具有您的“路径”参数的语法)