Question

I have searched for this question, but I haven't found a good answer.

Even the Wikipedia Article on URIs does not explain it thoroughly. I thought it was the protocol for accessing a web page. e.g. HTTP/HTTPS/FTP, but the wiki article says otherwise.

Some URI schemes are not associated with any specific protocol (e.g. "file") and many others do not use the name of a protocol as their prefix (e.g. "news").

I know what part of the URL is the scheme. But my real question was what does it do?

Was it helpful?

Solution

Okay, I know what part of the URL is the scheme. But my real question was what does it do?

It simply tells you how to interpret the part of the URL after the colon.

For example, in file://usr/share/doc, the file tells me the part after the colon should be interpreted as a locally-available filesystem path. This isn't identical to a protocol, because there is no transport layer or encoding - a client just uses regular local system calls to access it.

Conversely, https://programmers.stackexchange.com specifies a scheme (https, which in turn means "HTTP over TLS"), but still requires the client to make its own choices about the physical transport used to reach it.

OTHER TIPS

The quote from Wikipedia may be a bit misleading. What it means is that for example the file: URI scheme does not state what kind of way is used to accessing the data (or whatever it is pointing to). With http: you know there is the HTTP protocol being used. With file: it's whatever the applications wants to use.

With news: the protocol name is NNTP, but the name doesn't reflect that. Which is a good thing in my mind, since news: is a lot clearer.

So the URI scheme is just the first part including the colon.

The scheme indicates the addressing system used. URL's are really a unification of various disparate addressing systems. The part before the colon identifies the scheme in use, and everything after the colon is syntax specific for the scheme. Each scheme defines its own unique way of addressing resources. This makes the URL standard infinitely extensible through adding new schemes.

It is hard to say anything in general for schemes, because they are wildly different. In many cases the name of the scheme is the name of a protocol which can be used to fetch the resource (like http, https, ftp etc.) but that is not hard rule, eg. the 'mailto' scheme indicates an e-mail address, but not a particular protocol. Some schemes does not correspond to any specific protocol, like the 'about' scheme used in web browsers, where the resource is not fetched via a protocol at all, but is built-in in the client.

I like Apple's description:

A URL scheme is the part of a link that specifies the type of application your device uses to open a URL. Many apps support URL schemes: FaceTime uses URL schemes to make calls when a URL starting with facetime:// is opened, just like Safari handles URLs starting with http://.

Shortcut’s URL scheme, shortcuts://, launches the Shortcuts app from a link to perform a task such as importing or running a shortcut. These links can be useful in many different contexts such as on the web or when using Shortcuts with other apps that support opening URLs

Source

It's the part before the colon in a URI.

For example: the scheme for http://en.wikipedia.org/ is http. The scheme for file:///etc/passwd is file. The scheme for ftp://example.org/resource.txt is ftp.

The scheme is the first hierarchy of an URI and therefore the most 'prominent' part, which is used to identify the 'purpose' of the resource. If you are interested in some 'kind' of resource (web links, news, files), you can tell by just using checking the scheme - not the whole resource string.

It's just a string repesenting a set of resources.

Licensed under: CC-BY-SA with attribution
scroll top