preface
URI is an important part of HTTP protocol. It is a string used to identify the name of an Internet resource. This identity allows users to interact with any resource over a specific protocol.
What’s the use of a URI? Here’s an example:
When there is no URI, if Sam wants to share a video with Sam, then Sam should tell Sam the following requirements:
- In order to use
FTP
Agreement to accesszhangsanvideo.com
The port is8088
. - The login user name is
lisi
, the password islisi
. - And then I’m going to enter
/share/video
Directory. - Download,
sharetolisi.flv
File.
When you have a URI, everything becomes very simple. All you need is a single string. ftp://lisi:[email protected]:8088/share/video/sharetolisi.flv
This is the power of urIs.
Uris differ from urls and UrNs
What is the URL
The URL is defined in the RFC1738 document. Full name: Uniform Resource Locator. It is also commonly known as the website address. It represents the location of a resource, like a house tag on a network.
The standard format of the UNIFIED Resource Locator is as follows :[Protocol type]://[Server address]:[port number]/[Resource-level UNIX file path][file name]? [query]#[fragment ID]
[Port number], [Query], and [segment ID] are optional.
A URL in the HTTP protocol encapsulates the five basic elements of getting information from the Internet in a simple address: 3. Certificate information needed to access resources (can be omitted) 4. Server (usually domain name, sometimes IP address) 5. Port number (represented by number, If the value is the default value, you can omit it. 6. Path (Use “/” to distinguish each directory name in the path.) 7. In order to? Each parameter is separated by &, and the parameter name and value are separated by =. UTF8 URL encoding is usually used to avoid character collisions.
With https://juejin.im:80/search? Query =vue&type=all
https
, it is the agreementjuejin.im
Is the server443
Is the port number/search
That is a path? query=vue&type=all
That is to ask
Most browsers do not require the user to enter the protocol section (https:// in the URL above) because most web content is HTTP/HTTPS. Similarly, 80 is the HTTP port number and 443 is the HTTPS port number. Therefore, it is not necessary to specify the port number.
Because the HTTP protocol allows the server to redirect the browser to another web address, many servers allow users to omit parts of a web address, such as WWW.
What is the URN
URN is defined in RFC2141. URN is a Uniform Resource Name. The expectation is to provide persistent, location-independent identification of resources and to allow simple mapping of multiple namespaces to a single URN namespace.
The existence of a URI does not necessarily mean that the identified resource is available, while it needs to remain globally unique and persistent, even if the resource no longer exists or becomes unavailable.
Urns are historical names for URIs, and their use has been supplanted by URIs only since they were published.
What is a URI
Uris are Uniform Resource identifiers (uris) defined in RFC1630. It is a string that identifies the name of an Internet resource.
The URI grammar consists of the URI protocol name (such as HTTP, FTP, mailto, file), a colon, and the corresponding content of the protocol. A specific protocol defines the syntax and semantics of the protocol content, and all protocols must follow certain general rules of URI grammar, that is, some special characters are reserved for some special purposes. URI grammas also impose additional restrictions on protocol content for a variety of reasons, such as ensuring interoperability between layered protocols. The percent encoding also provides additional information for the URI.
The format of a common URI is as follows :[Protocol name]://[User name]:[Password]@[host name]:[port]/[path]? [query parameter]#[fragment ID]
As shown in the figure:
The relationship between URL, URN, and URI
Urns and urls are already urIs. As shown in the figure:
A URI is a rule that uniquely identifies a resource. In real life, a URI is an ID number. The home address also identifies the person, so the home address is also a URI.
A URL uniquely identifies a person by describing their location. Example: Address agreement :// China/Guangdong Province/Guangzhou city/Panyu District/some university/some dormitory/some dormitory/Zhang SAN
As you can see, this string also identifies a unique person and acts as a URI, so the URL is a subset of the URI.
An ID number can also uniquely identify a person. For Zhang SAN in Guangzhou, the identification number is 440XXXXXXXXXXXXxxx. So URNs are also a type of URI.
Uniquely identifying a person, either by location or by ID, is an implementation of a URI.
Because URNs haven’t caught on, URIs on the Internet are almost invariably urls.
At the end
For more articles, please go to Github, if you like, please click star, which is also a kind of encouragement to the author.