What do we call the combined path, query, and fragment in a URI?

我只是一个虾纸丫 提交于 2019-12-08 19:10:46

问题


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?


回答1:


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).




回答2:


I'm not aware of any term for that portion of a URI.

RFC3986 says this

     foo://example.com:8042/over/there?name=ferret#nose
     \_/   \______________/\_________/ \_________/ \__/
      |           |            |            |        |
   scheme     authority       path        query   fragment
      |   _____________________|__
     / \ /                        \
     urn:example:animal:ferret:nose



回答3:


RFC 7230 says:

request-line = method SP request-target SP HTTP-version CRLF

I personally prefer to use the terms

  • origin for scheme and authority (where) and
  • resource for path, query string and fragment (what).


来源:https://stackoverflow.com/questions/47543432/what-do-we-call-the-combined-path-query-and-fragment-in-a-uri

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!