How can I check if XHR is working with HTTP / 2.0?
1 answer
Since the status bar is excluded from the returned string getAllResponseHeaders
and HTTP / 2 does not define how the version ... that is included in the HTTP / 1.1 status bar is migrated , you cannot detect the version in reliable mode.
However, some versions of some browsers, notably Safari 10-do, carry over the version by adding HTTP/2.0
property reasons before the phrase statusText
.
if (req.statusText.startsWith('HTTP/2.0 '))
// HTTP/2.0 enabled
else
// we don't know either way
+3
source to share