Thursday 20 October 2016

http - What is the difference between a URI, a URL and a URN?



People talk about URLs, URIs, and URNs as if they're different things, but they look the same to the naked eye.



What are the distinguishable differences between them?



Answer



From RFC 3986:




A URI can be further classified as a locator, a name, or both. The
term "Uniform Resource Locator" (URL) refers to the subset of URIs
that, in addition to identifying a resource, provide a means of
locating the resource by describing its primary access mechanism
(e.g., its network "location"). The term "Uniform Resource Name"
(URN) has been used historically to refer to both URIs under the

"urn" scheme [RFC2141], which are required to remain globally unique
and persistent even when the resource ceases to exist or becomes
unavailable, and to any other URI with the properties of a name.




So all URLs are URIs (actually not quite - see below), and all URNs are URIs - but URNs and URLs are different, so you can't say that all URIs are URLs.



EDIT: I had previously thought that all URLs are valid URIs, but as per comments:





Not "all URLs are URIs". It depends on the interpretation of the RFC. For example in Java the URI parser does not like [ or ] and that's because the spec says "should not" and not "shall not".




So that muddies the waters further, unfortunately.



If you haven't already read Roger Pate's answer, I'd advise doing so as well.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...