Whats the difference between a scheme and a protocol in a URL?
Asked Answered
A

6

62

I'm hoping someone can clarify to me the technical difference between a protocol and a scheme in a url. (or identify the rest of the items that can also be placed in a scheme?)

Originally I had thought they were the same and that scheme was just another name for it.

You can find scheme referenced here in this wikipedia article.

Although according to an answer here a scheme is not considered to be a protocol because:

there is no transport layer or encoding

Is this the proper way that defines their difference or is there more to it that makes the two different?

How can I distinctly tell when I'm dealing with a protocol or scheme? (or something other than a protocol that also qualifies to be used in a scheme? since it seems that protocols get placed in the scheme part of a url)

Antidromic answered 23/2, 2018 at 17:31 Comment(0)
C
49

My understanding is that the two terms have a significant overlap. The protocol being the agreed upon method of information transfer and the scheme being the identifier that URLs use to express what type of protocol the specific resource should be served over. In short, schemes are simply identifiers for protocols.

For example

In the link https://example.com, https is the scheme that tells the browser (or whoever the requester of that resource is) that the resource at example.com will be served over the Hypertext Transfer Protocol Secure (HTTPS), which is the type of "protocol".

Scheme <> Protocol

ftp <> File Transer protocol
http <> Hypertext Transfer Protocol
https <> Hypertext Transfer Protocol Secure
Caritta answered 23/2, 2018 at 19:43 Comment(4)
Ok thanks for this answer. I just want to clarify what you meant with mailto: and when you say - "In short, schemes are simply identifiers for protocols." - Does this mean that "mailto:" is an identifier for a protocol that has a different name from "mailto:" or is the action/function of the mailto-scheme a completely different thing that no protocol is initiated at all with it?Antidromic
@Antidromic Ahh I just made an edit because I was actually incorrect. There is a mailto protocol and the scheme syntax is also mailto. So in this case the protocol name is the same as the scheme syntaxCaritta
"While most URI schemes were originally designed to be used with a particular protocol, and often have the same name, they are semantically different from protocols. For example, the scheme http is generally used for interacting with web resources using HTTP, but the scheme file has no protocol" en.wikipedia.org/wiki/Uniform_Resource_IdentifierFaddist
There is no mailto protocol, but rather SMTP. That's a good example in which scheme and protocol differ. Same for the file scheme, which corresponds to no protocol, it simply points to a local file.Parasitology
H
17

A scheme and protocol are not the same, so to answer your question, technically there isn't a protocol in the URL, only a scheme.

To know what the protocol is you need to inspect the request.

Consider your URL is (quoted from @clayjones94 answer):

https://example.com

And your HTTP request (snippet) starts with:

GET / HTTP/1.1
Host: example.com

...

https would be the scheme

HTTP/1.1 would be the protocol

The reason people mix the two or interchange them is because they are inferring the protocol based on the scheme, but you can't really do that because you could be using either the HTTP/1.1 or HTTP/2 protocol to send a request to https://example.com, which is using the https scheme.

Hermaphroditus answered 17/1, 2021 at 2:16 Comment(3)
So you're saying that a scheme is an identifier for a family of protocols with the same name, but possibly different versions.Parasitology
No, in a nutshell I'm saying the two are not the same or related, and the reason I'm saying this is that the other answers try to relate the two and I've gave reasons in my answer as to why you can't do this.Hermaphroditus
I think it's natural to mix the protocol with the scheme because in most URLs most people use there is a 1-1 relationship between a scheme and a protocol or a family of network protocols (e.g. http, ftp, ssh, ldap). I think that other counterexamples in which the scheme has nothing to do with a network protocol name (e.g. file, mailto) would make the difference between both concepts clearer.Parasitology
C
9

A network protocol is a communication system of rules for transferring data. A scheme is a systematic plan for a data structure.

A URI does not contain a protocol but does contain a scheme [1]. A scheme can be associated with a protocol but does not have to. E.g. the http: scheme is associated with the HTTP/1.0 or 1.1 protocol [2] but the file: scheme is not associated with any protocol. Http is a scheme and a protocol whereas file is a scheme but not a protocol.

[1] https://en.wikipedia.org/wiki/Uniform_Resource_Identifier 29/01/21

[2] https://www.w3.org/2001/tag/doc/SchemeProtocols.html#useNaturalProtocol 29/01/21

Coltish answered 29/1, 2021 at 9:59 Comment(0)
D
3

I like to think of the term "scheme" as the region of the URL that indicates the "protocol".

 the scheme
 ┌───┐
 https://www.google.com/
 └───┘
 the specific protocol
Derive answered 11/7, 2018 at 4:40 Comment(1)
This is not technically correct. the ":" is a delimiter and not part of the scheme itself, and the "//" denotes the start of the authority component. As you can see by the formal definition, the ":" and "/" characters are not even allowed in the scheme, and none of the officially registered schemes include them. What you have denoted as the protocol is also the scheme in this case.Falzetta
C
1

A scheme is more like a command to the client. In a few cases, the client typically interprets the scheme by opening a connection using some related protocol, but in many others, it just launches some program, e.g. mailto, telnet, slack, spotify.

Technically, a scheme is a "namespace" that implies a way to interpret the rest of the URL to identify a "resource". What the client does with that resource is up to it, typically it will "display" it to the user somehow.

Caressa answered 12/12, 2023 at 13:29 Comment(0)
P
-1

A protocol can be described as "scheme+version" if the scheme is HTTP then there are 2 protocols HTTP1.1 and HTTP2.0 so in a nutshell a protocol can be vaguely termed as the specific version of a scheme

Preachy answered 28/6, 2022 at 6:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.