我们将 URI 中的组合路径、查询和片段称为什么? [英] What do we call the combined path, query, and fragment in a URI?

查看:53
本文介绍了我们将 URI 中的组合路径、查询和片段称为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个URI由几个部分组成:scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment].通常,我发现自己想要引用主机和端口右侧的整个 URI 部分 - 这部分将被视为 HTTP 请求中的 URI:

GET/path?query#fragment主机:example.com

作为简写,我通常称其为路径",但这并不十分准确,因为路径只是其中的一部分.这本质上是 URL 的整个第一部分称为什么?

是否有一个商定的名称?

解决方案

在完整的 HTTP URI 中,似乎没有一个术语表示 authority 之后的所有内容.

如果您仅将相关部分作为 URI 引用(例如,在 HTTP GET 请求中),则称为 相对参考:

<块引用>

relative-ref = relative-part [ "?"查询] [#"片段]

但该术语还包括网络路径引用(通常称为protocol-relative URI),例如//example.com/path?query#fragment.要排除这种情况,您可以使用其他两种情况的术语:

  • 绝对路径引用(以单个/开头,例如/path?query#fragment)
  • 相对路径引用(不以 / 开头,例如 path?query#fragment>)¹
<小时>

¹ 如果第一个路径段包含 :,则必须以 ./ 开始相对路径引用(例如,./pa:th?query#fragment).

A URI is composed of several parts: scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]. Often, I find myself wanting to refer to the entire part of the URI to the right of the host and port - the part that would be considered the URI in an HTTP request:

GET /path?query#fragment
Host: example.com

As a short-hand, I normally call this the "path", but that's not quite accurate, as the path is only part of it. This is essentially the inverse of What do you call the entire first part of a URL?

Is there an agreed-upon name for this?

解决方案

Within a full HTTP URI, there doesn’t seem to be a term that denotes everything coming after the authority.

If you only have the part in question as a URI reference (e.g., in a HTTP GET request), it’s called a relative reference:

relative-ref  = relative-part [ "?" query ] [ "#" fragment ]

But this term also includes network-path references (often called protocol-relative URIs), e.g. //example.com/path?query#fragment. To exclude this case, you could use the terms for the other two cases:

  • absolute-path reference (begins with a single /, e.g. /path?query#fragment)
  • relative-path reference (doesn’t begin with a /, e.g., path?query#fragment

¹ If the first path segment contains a :, you have to begin the relative-path reference with ./ (e.g., ./pa:th?query#fragment).

这篇关于我们将 URI 中的组合路径、查询和片段称为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆