什么是URI、URL和URN

相关概念

  • URI:Uniform Resource Identifier,即统一资源标志符,用来唯一的标识一个资源。
  • URL:Uniform Resource Locator,统一资源定位符。即URL可以用来标识一个资源。
  • URN:Uniform Resource Name,统一资源命名。即通过名字来表示资源的。

在这里插入图片描述

URI是以一种抽象的,高层次概念定义统一资源标识;而URL和URN则是具体的资源标识的方式。URL和URN都是一种URI。


URI(统一资源标志符)

服务器资源名被统称为统一资源标识符;就像邮政地址,URI可以唯一地标识一个资源的信息。URI有两种形式,即URL和URN。
格式: [//[user:password@]host[:port]][/]path[?query][#fragment]

root:123456@(127.0.0.1:3306)/testdb?charset=utf8
ftp://ftp.is.co.za/rfc/rfc1808.txt
http://www.ietf.org/rfc/rfc2396.txt
ldap://[2001:db8::7]/c=GB?objectClass?one
mailto:John.Doe@example.com
news:comp.infosystems.www.servers.unix
tel:+1-816-555-1212
telnet://192.0.2.16:80/
urn:oasis:names:specification:docbook:dtd:xml:4.1.2undefined

URL(统一资源定位符)

URL描述了一台特定服务器上某资源的特定位置。它们可以明确说明如何从一个精准、固定的位置获取资源。

https://developer.mozilla.org
https://developer.mozilla.org/en-US/docs/Learn/
https://developer.mozilla.org/en-US/search?q=URL
https://tools.ietf.org/html/rfc2396#section-3.1

URL格式:
在这里插入图片描述

  1. Protocol 访问资源所使用的协议类型 。
  2. Domain 请求的域名,表明正在请求的服务器,也可直接使用IP。
  3. Port 指定服务器连接的网络端口号,此项是可选项,若省略则自动使用默认端口号。
  4. Path 指定服务器上的文件路径来定位特指的资源。
  5. Fregment 使用片段标识符通常可标记出已获取资源中的子资源(文档中的某个位置)。
  6. Quering String 针对已指定的文件路径内的资源,可以使用查询字符串传入任意参数。

Golang中url.URL定义:

type URL struct {
	Scheme      string
	Opaque      string    // encoded opaque data
	User        *Userinfo // username and password information
	Host        string    // host or host:port
	Path        string    // path (relative paths may omit leading slash)
	RawPath     string    // encoded path hint (see EscapedPath method)
	ForceQuery  bool      // append a query ('?') even if RawQuery is empty
	RawQuery    string    // encoded query values, without '?'
	Fragment    string    // fragment for references, without '#'
	RawFragment string    // encoded fragment hint (see EscapedFragment method)
}

URN(统一资源命名)

URN是作为特定内容的唯一名称使用的,与目前的资源所在地无关。如图书的编号(ISBN)urn:isbn:0451450523

在这里插入图片描述


参考

https://whatis.techtarget.com/definition/URI-Uniform-Resource-Identifier
https://www.ionos.com/digitalguide/websites/web-development/uniform-resource-identifier-uri/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值