Upgrade

The HTTP Upgrade header indicates that the sender wants to upgrade the existing HTTP/1.1 connection.

Usage

This HTTP header can be used as part of either a HTTP request or response. It is not supported by HTTP/2.

Request Header

The HTTP Upgrade request header is employed to upgrade a HTTP Connection protocol from HTTP/1.1 to HTTP/2, HTTP/1.1 to HTTPS, or from HTTP/1.1 to WebSocket.

Protocol choices are listed on a single line in order of descending preference. This is the only directive for this HTTP header.

Note

The HTTP Connection header is mandatory when the HTTP Upgrade header is present.

Server Acknowledgement and Continuation

Servers can choose to ignore the upgrade request and in such cases, the HTTP response will be the same as if occurred had the HTTP header not been present.

When the server upgrades the HTTP connection, it will return with a 101 Switching Protocols status code, which will include an HTTP Upgrade response header to indicate the new protocol. Once this is done, and as long as the new protocol is capable of completing the original HTTP request, a response to the original HTTP request will be sent.

Response Header

The HTTP Upgrade response header is sent by a server as part of HTTP error 426 Upgrade Required. This indicates that a server is unwilling to process the HTTP request using the current protocol but may, however, be willing to do so if it is upgraded to one specified by this HTTP response header.

Example

In this example, the client requests that the HTTP Connection be upgraded from HTTP/1.1 to HTTP/2 and if not available, upgraded to HTTPS.

HEAD / [[1.1|HTTP/1.1]]
Host: www.example.re
Connection: upgrade
Upgrade: HTTP/2, HTTPS

Takeaway

The HTTP Upgrade header is included in a HTTP request or a response for the other party to upgrade the connection to one specified by the HTTP header. It is only supported by HTTP/1.1.

See also

Last updated: August 2, 2023