第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

首頁 慕課教程 HTTP 入門教程 HTTP 入門教程 統(tǒng)一資源標(biāo)志符-URI

統(tǒng)一資源標(biāo)志符-URI

URI,統(tǒng)一資源標(biāo)志符(Uniform Resource Identifier, URI),標(biāo)識了網(wǎng)絡(luò)中的某個對象或者集合。它可以是 Web 系統(tǒng)中的某個圖片地址,也可以是某個人的郵箱地址。下面我們將詳細(xì)了解 URI 的定義,格式,以及 URI 和 URL 的區(qū)別。

1. URI 定義

1.1 什么是RFC

RFC 是一個文檔,這個文檔有點大也足夠權(quán)威,以至于有人稱它是互聯(lián)網(wǎng)界的圣經(jīng)。里面收錄了互聯(lián)網(wǎng)開發(fā)中的各種協(xié)議規(guī)范,對 URI 的定義在 RFC2396 也有對應(yīng)的記錄。

Tips:RFC 文件是由 Internet Society(ISOC)贊助發(fā)行的,由一個個編號排列起來的文件。

1.2 RFC2396 解讀

RFC2396 的規(guī)約中對 URI 3 個單詞有如下定義:
Uniformity

Uniformity provides several benefits: it allows different types of
resource identifiers to be used in the same context, even
when the mechanisms used to access those resources may differ; it allows uniform semantic interpretation of common syntactic conventions across different types of resource identifiers; it allows introduction of new types of resource identifiers without interfering with the way that existing identifiers are used; and, it allows the identifiers to be reused in many different contexts, thus permitting new applications or protocols to leverage a pre-existing, large, and widely-used set of resource identifiers.

有一個統(tǒng)一的格式,這個格式允許我們訪問不同類型的資源,即使他們有同樣的上下文,并且這個格式是可擴展的,允許后面有新的協(xié)議加入。

Resource

A resource can be anything that has identity. Familiar examples include an electronic document, an image, a service (e.g., “today’s weather report for Los Angeles”), and a collection of other resources. Not all resources are network “retrievable”; e.g., human beings, corporations, and bound books in a library can also be considered resources. The resource is the conceptual mapping to an entity or set of entities, not necessarily the entity which corresponds to that mapping at any particular instance in time. Thus, a resource can remain constant even when its content—the entities to which it currently corresponds—changes over time, provided that the conceptual mapping is not changed in the process.

資源是任何可標(biāo)識的東西,文件圖片甚至特定某天的天氣等,它是一個或者一組實體的概念映射。

Identifier

An identifier is an object that can act as a reference to something that has identity. In the case of URI, the object is a sequence of characters with a restricted syntax.

表示可標(biāo)識的對象。也稱為標(biāo)識符。

2. 格式

scheme 一般指的是協(xié)議,URI 的通用格式并沒有太多限制,一般是如下,以 scheme 開頭,冒號 “:” 分隔開。

  <scheme>:<scheme-specific-part>

雖然 URI 的格式?jīng)]怎么限制,但是不同 scheme 一般會遵循下面的格式來定義。

<scheme>://<authority><path>?<query>

以 scheme = http 加以說明:

 http://www.imocc.com:80/index.htm?id=3937

Http 的 <authority>模塊一般不會寫在路徑上面,即使是 Basic Authorization 也是將用戶名密碼 base64(user:passwd) 寫在 head 里面。

下面的例子說明 RUI 的一般用法:

3. URL

通過前面我們知道 URI 是網(wǎng)絡(luò)中用于標(biāo)識某個對象的規(guī)約,URI 包含了多個 <scheme>,所以 URL 是 scheme = http 的 URI。URL 是 URI 的子集,只要是 URL 一定就是 URI ,反過來不成立。

URL 和 URI 只差了一個字母,Location 和 Identifier:
Location:定位,著重強調(diào)的是位置信息;
Identifier:標(biāo)識,只是一種全局唯一的昵稱。

舉例:

美國是一個國家,它只是一種標(biāo)識,通過美國這兩個字我們無法知道這個國家在哪里。如果這個標(biāo)識換成了經(jīng)緯度,那我們就能知道這個經(jīng)緯度對應(yīng)的是美國,并且知道美國所處的位置信息。

4. 小結(jié)

本小節(jié)主要學(xué)習(xí)了 URI 的概念,并且區(qū)分出了大家容易誤解的 URI 和 URL 的區(qū)別。在新版的 Http/2.0 文檔中已經(jīng)將 URL 修改成了 URI,可能也是怕大家混淆,不過在詳細(xì)地了解清楚后,改不改問題都不大了。