-3

Saw below definition on https://http2.github.io/:

What is HTTP/2?

HTTP/2 is a replacement for how HTTP is expressed “on the wire.” It is not a ground-up rewrite of the protocol; HTTP methods, status codes, and semantics are the same, and it should be possible to use the same APIs as HTTP/1.x (possibly with some small additions) to represent the protocol.

The focus of the protocol is on performance; specifically, end-user perceived latency, network and server resource usage. One major goal is to allow the use of a single connection from browsers to a Web site.

My questions are:

  1. In the above definition, "single connection from browsers to a Web site". What does it mean? Because we can open multiple instances of a website from a browser.
  2. While writing an API, how can I specify that HTTP/2 protocol should be invoked?
  3. When we say the HTTP/2 protocol. Does it include HTTP also or it's just the term for new protocol only?

PS: Not sure about the title of the question, feel free to correct it.

2
  • "While writing an API" Could you please clarify why you think that the transport protocol used would affect your API. What kind of API are you referring to? Just the servers implementation for the transport? Feb 15, 2020 at 8:47
  • Do you know how HTTP 1 works?
    – user253751
    Jul 23, 2020 at 20:44

1 Answer 1

2
  1. In the above definition, "single connection from browsers to a Web site". What does it mean? Because we can open multiple instances of a website from a browser.

That you have multiple instances of a website handled in a browser, doesn't imply you need multiple underlying connections.

  1. While writing an API, how can I specify that HTTP/2 protocol should be invoked?

You can't force the usage of the HTTP/2 protocol from a browser, since it's the client that initiates the connection handshake.

References:

  1. When we say the HTTP/2 protocol. Does it include HTTP also or it's just the term for new protocol only?

No, these protocols are entirely different. The latter reference answers this (emphasis mine):

"A browser that only supports HTTP/2" does not exist; if they support HTTP/2, they also support HTTP/1.1. But let's assume that such browser exist.

In this latter case, the server will see the connection preface and will not recognize the PRI method. What exactly the server does in this case depends on the server. It may return a 400 Bad Request, or perhaps just close the connection, or it may trigger an internal server error.


Nowadays you can fairly assume that all modern browsers use the HTTP/2 protocol for sake of speed and saving resources.

Also why do you think that would be important for building a HTTP based API?

API's based on HTTP (e.g. webservices based on SOAP, REST, etc.) use that as a transport service, and should be entirely agnostic about the transport layers details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.