52

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)

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Jonathan002
  • 9,639
  • 8
  • 37
  • 58

5 Answers5

38

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
ᴇʟᴇvᴀтᴇ
  • 12,285
  • 4
  • 43
  • 66
clayjones94
  • 2,648
  • 17
  • 26
  • 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? – Jonathan002 Feb 24 '18 at 16:50
  • @Jonathan002 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 syntax – clayjones94 Feb 26 '18 at 17:42
  • 9
    "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" https://en.wikipedia.org/wiki/Uniform_Resource_Identifier – YouHaveNoSkill Jan 19 '20 at 02:18
  • 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. – Alan Evangelista Aug 02 '21 at 09:16
14

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.

Professor of programming
  • 2,978
  • 3
  • 30
  • 48
  • So you're saying that a scheme is an identifier for a family of protocols with the same name, but possibly different versions. – Alan Evangelista Aug 02 '21 at 09:06
  • 1
    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. – Professor of programming Aug 03 '21 at 11:25
  • 1
    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. – Alan Evangelista Aug 03 '21 at 12:55
8

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

Timo Richter
  • 165
  • 1
  • 3
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
Mike Kormendy
  • 3,389
  • 2
  • 24
  • 21
  • 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](https://tools.ietf.org/html/rfc3986#section-3.1), the ":" and "/" characters are not even allowed in the scheme, and none of the [officially registered schemes](https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml) include them. What you have denoted as the protocol is also the scheme in this case. – Todd Menier Jul 29 '19 at 15:30
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