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

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

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

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

1. URI 定義

1.1 什么是RFC

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

Tips:RFC 文件是由 Internet Society(ISOC)贊助發(fā)行的,由一個(gè)個(gè)編號(hào)排列起來(lái)的文件。

1.2 RFC2396 解讀

RFC2396 的規(guī)約中對(duì) URI 3 個(gè)單詞有如下定義:
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.

有一個(gè)統(tǒng)一的格式,這個(gè)格式允許我們?cè)L問(wèn)不同類型的資源,即使他們有同樣的上下文,并且這個(gè)格式是可擴(kuò)展的,允許后面有新的協(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)識(shí)的東西,文件圖片甚至特定某天的天氣等,它是一個(gè)或者一組實(shí)體的概念映射。

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)識(shí)的對(duì)象。也稱為標(biāo)識(shí)符。

2. 格式

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

  <scheme>:<scheme-specific-part>

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

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

以 scheme = http 加以說(shuō)明:

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

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

下面的例子說(shuō)明 RUI 的一般用法:

3. URL

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

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

舉例:

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

4. 小結(jié)

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