统一资源标志符
发布时间:2023-06-12 13:37:03 所属栏目:教程 来源:
导读:URI,统一资源标志符(Uniform Resource Identifier, URI),标识了网络中的某个对象或者集合。它可以是 Web 系统中的某个图片地址,也可以是某个人的邮箱地址。下面我们将详细了解 URI 的定义,格式,以及 URI 和 UR
URI,统一资源标志符(Uniform Resource Identifier, URI),标识了网络中的某个对象或者集合。它可以是 Web 系统中的某个图片地址,也可以是某个人的邮箱地址。下面我们将详细了解 URI 的定义,格式,以及 URI 和 URL 的区别。 1. URI 定义 1.1 什么是RFC RFC 是一个文档,这个文档有点大也足够权威,以至于有人称它是互联网界的圣经。里面收录了互联网开发中的各种协议规范,对 URI 的定义在 RFC2396 也有对应的记录。 Tips:RFC 文件是由 Internet Society(ISOC)赞助发行的,由一个个编号排列起来的文件。 1.2 RFC2396 解读 RFC2396 的规约中对 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. 有一个统一的格式,这个格式允许我们访问不同类型的资源,即使他们有同样的上下文,并且这个格式是可扩展的,允许后面有新的协议加入。 资源是任何可标识的东西,文件图片甚至特定某天的天气等,它是一个或者一组实体的概念映射。 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. 表示可标识的对象。也称为标识符。 2. 格式 scheme 一般指的是协议,URI 的通用格式并没有太多限制,一般是如下,以 scheme 开头,冒号 “:” 分隔开。 <scheme>:<scheme-specific-part> 虽然 URI 的格式没怎么限制,但是不同 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 的一般用法: ftp://ftp.is.co.za/rfc/rfc1808.txt; gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles; http://www.math.uio.no/faq/compression-faq/part1.html; mailto:mduerst@ifi.unizh.ch; news:comp.infosystems.www.servers.unix; telnet://melvyl.ucop.edu/0 3. URL 通过前面我们知道 URI 是网络中用于标识某个对象的规约,URI 包含了多个 <scheme>,所以 URL 是 scheme = http 的 URI。URL 是 URI 的子集,只要是 URL 一定就是 URI ,反过来不成立。 URL 和 URI 只差了一个字母,Location 和 Identifier: Location:定位,着重强调的是位置信息; Identifier:标识,只是一种全局唯一的昵称。 (编辑:汽车网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |