本文介绍了URL路径段中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

URL格式有一件有趣的事情:
URL路径段中的参数.

There is one interesting thing in URL format:
Parameters in Path Segments of URL.

有关更多信息,请参见
中的"2.2.5"部分" O'Reilly-HTTP-权威指南".

For more information see section "2.2.5" in
"O'Reilly - HTTP - The Definitive Guide".

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

This book can be found freely in Internet.

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

or in official specificationhttps://www.ietf.org/rfc/rfc2396.txtsection 3.3.

路径组件包含特定于授权机构(或 方案(如果没有权限组件),则标识资源
在该计划和权限的范围内.

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:

Let's consider the following URL:

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

此处/first-segment/second-segment/index.html是URL的路径部分.

Here /first-segment/second-segment/index.html is a Path part of URL.

  1. first-segment是该路径的第一段
  2. second-segment是该路径的第二段
  3. index.html是该路径的第三段
  1. And first-segment is a first segment of that Path
  2. second-segment is a second segment of that Path
  3. index.html is a third segment of that Path

该书中指出,每个段都可以有单独的参数,并用分号;"分隔.在我们的示例中,可能是:

It is stated in that book that each segment could have individual Parameters separated by semicolon ";". In our example it could be:

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. s1s2-second-segment
  3. 的参数index.html
  4. i1abc参数
  1. Here f1 - parameter for first-segment
  2. s1 and s2 - parameters for second-segment
  3. i1 and abc parameters for index.html

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

The question is: do you know any practical examples of such Parameters in URLs?

推荐答案

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

I do not know any example of exactly parameters in the path segment.

但最接近的示例是(已过期) SFTP URL提议.

But close example is connection and SFTP parameters in (expired) SFTP URL proposal.

有一个建议的连接参数,SSH主机密钥指纹的fingerprint:

There's one proposed connection parameter, the fingerprint for SSH host key fingerprint:

sftp://username:password;[email protected]/

和一个建议的 SFTP参数,用于传输模式的typecode(ASCII与二进制).没有官方示例,但应该像这样:

And one proposed SFTP parameter, the typecode for transfer mode (ascii vs. binary). There's no official example, but it should be like:

sftp://username:[email protected]/path/file;typecode=i

(实际上在语义上有所不同,但具有"path"参数的语法)

(what actually, while semantically different, has the syntax of your "path" parameter)

这篇关于URL路径段中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 15:19