An HTTP Upgrade request is a mechanism in HTTP protocol that allows client to request the server to switch to a different protocol for communication purposes during connection. It is commonly used when wanting to switch from HTTP 1.1 to
HTTP 2 or WebSockets.

How it works

Client sends Upgrade Request

The client includes Upgrade in a header of an HTTP request, indicating to which protocol it wants to switch to. That request typically uses the Connection: Upgrade header to signify the upgrade intention.

Example

GET /chat HTTP1.1  
HOST: example.com  
Upgrade: websockets  
Connection: Upgrade  

Server Responds

Once server gets a request, it switches the protocol (if it supports it) and retursn 101 Switching Protocols status code and confirms the protocl in Upgrade Header.

HTTP/1.1 101 Switching Protocols  
Upgrade: websockets  
Connection: Upgrade  

Protocol Switch

Once server confirms the switch, both client and server switch to using a new protocol over the same TCP connection.

Common Use Cases