• URI与URL


    背景

    项目需要自己构造一个URI Scheme,但是不知道URI是什么,以及Scheme的命名方式,所以找了以下资料。

    资料

    URL非常好理解,因为很常见,它是用于网络上定位互联网上Web资源的,如网上的某个图片,某个mp3或某个H5页面的地址。
    举例:http://www.baidu.com/img/bdlogo.png

    而URI和URL并不等同,定义如下

    URI:Uniform resource identifier 统一资源标识符

    URL:Uniform resource locator 统一资源定位符

    维基百科:

    The most common form of URI is the uniform resource locator (URL)

    所以URL是URI的子集

    URI是一个资源定位符,并不一定是网络上的,它可以是你本机上的。

    举例:

    https://example.org/absolute/URI/with/absolute/path/to/resource.txt
    ftp://example.org/resource.txt
    ed2k://|file|%5BMAC%E7%89%88%E6%9E%81%E5%9

    URI Scheme是一个规范,所以符合它的规范的都可以称之为URI Scheme,所以我们也可以设计自己的scheme。

    scheme:[//[user:password@]domain[:port]][/]path[?query][#fragment]

    <scheme name> : <hierarchical part> [ ? <query> ] [ # <fragment> ]

    <scheme name>:scheme的名称,对于上面3个scheme,它们scheme名分别是http, ftp, ed2k(电驴协议)

    <hierarchical part>:路径名,一般为authority+path,见下图即知

    <query>:查询字段,一般为键值对,参考URL即知

    <fragment>:可选字段,经常看到网页中用来回到顶部的就是这个啦

    关于Scheme的命名方式,维基百科如是说 

    The scheme consists of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus (+), period (.), or hyphen (-). Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters.

  • 相关阅读:
    Java openrasp学习记录(一)
    Java ASM3学习(3)
    Java ASM3学习(2)
    Java Instrumentation插桩技术学习
    Java ASM3学习(1)
    从JDK源码学习HashSet和HashTable
    从JDK源码学习HashMap
    从JDK源码学习ArrayList
    Java XXE漏洞典型场景分析
    CVE-2020-7961 Liferay Portal 复现分析
  • 原文地址:https://www.cnblogs.com/chenyg32/p/4790365.html
Copyright © 2020-2023  润新知