Sunday, October 18, 2020

Chrome Networking - Why does the protocol say h2?

Sometimes it was showing as http 1.1 and other sites was showing as h2. 

What is h2?

HTTP/1.1: the “classic” HTTP protocol, known and loved for over 15 years

SPDY/3.1: Google’s first version of the HTTP/2 spec, formed the basis of HTTP/2

H2-14: H2 stands for “HTTP 2”, the 14 will refer to “draft 14” since the HTTP/2 spec isn’t final yet

H2C-14: H2C stands for “HTTP 2 Cleartext”, the HTTP/2 protocol over a non-encrypted channel


Now main thing was 

Is there a way to force an XMLHttpRequest to use HTTP/1.1?


I have a server endpoint that supports both HTTP/1.1 and HTTP2. For testing purposes, I want to try downloading content from the endpoint with both HTTP/1.1 and HTTP2 connections, possibly at the same time.


When I request data from the endpoint with an XMLHttpRequest, it automatically uses HTTP2, without me including the Connection: Upgrade header.


Is there a way to force an XMLHttpRequest to use HTTP/1.1 for the underlying TCP connection? What about other protocols, such as Quic or SPDY?


However, the answer is NO. The browser decides which protocol it wants to use as an implementation detail of the XmlHttpRequest object. You can't force a particular choice from inside your script.



References:

https://ma.ttias.be/view-http-spdy-http2-protocol-google-chrome/

No comments:

Post a Comment