28

This is one of the Node http events. Did the obvious Google Searches, didn't find much. What is it exactly?

Randomblue
  • 112,777
  • 145
  • 353
  • 547

1 Answers1

35

HTTP Upgrade is used to indicate a preference or requirement to switch to a different version of HTTP or to another protocol, if possible:

The Upgrade general-header allows the client to specify what additional communication protocols it supports and would like to use if the server finds it appropriate to switch protocols. The server MUST use the Upgrade header field within a 101 (Switching Protocols) response to indicate which protocol(s) are being switched.

   Upgrade        = "Upgrade" ":" 1#product

For example,

   Upgrade: HTTP/2.0, SHTTP/1.3, IRC/6.9, RTA/x11

The Upgrade header field is intended to provide a simple mechanism for transition from HTTP/1.1 to some other, incompatible protocol.

According to the IANA register, there are only 3 registered mentions of it (including one in the HTTP specification itself).

The other two are for:

Community
  • 1
  • 1
Bruno
  • 119,590
  • 31
  • 270
  • 376
  • Wow, very thorough. Thanks a bunch! – Randomblue Dec 11 '11 at 22:25
  • @Bruno, How does custom Upgrade protocols work? E.g. if our server wants to support [`Upgrade: firepresence`](http://lucumr.pocoo.org/2012/9/24/websockets-101/) a custom protocol, how can we get the browser to send the Upgrade request? – Pacerier Mar 16 '15 at 13:45
  • @Pacerier I'm not sure. I guess you'd need to change the browser itself substantially (or write a plugin/extension for it if possible), a bit like what was done for websockets. – Bruno Mar 16 '15 at 13:55
  • @Bruno `preference or requirement` as per section 6.7: `Upgrade cannot be used to insist on a protocol change.` So instead of a preference or a requirement, it's more of a "hey, if you can, use these protocols because they're better". – Qix - MONICA WAS MISTREATED Jul 10 '16 at 01:47