Upgrade Header

Table of Content

The Upgrade header in HTTP is used for switching or upgrading the protocol. This is mainly used for upgrading HTTP to a different protocol, particularly WebSocket and HTTP/2. Upgrading the protocol is useful for improving the performance and real-time capabilities of web communication, without requiring a separate connection for the upgraded protocol.

Syntax

The syntax of the Upgrade header is quite straightforward. You simply specify the protocol you want to upgrade to after the Upgrade: part of the header.

Upgrade: protocol-name[/protocol-version]

Directives

The main directive for the Upgrade header is simply the protocol you're upgrading to, and possibly the version of that protocol.

  • Protocol-name: The protocol you're wanting to switch to
  • Protocol-version: The version of the protocol you're wanting to switch to

Examples

A typical example would be upgrading HTTP to WebSocket:

Upgrade: websocket

Or for a HTTP/2 upgrade:

Upgrade: h2c

Browser Compatibility

Browser Compatibility
Chrome Supported
Firefox Supported
Safari Not Supported
Opera Supported
Edge Supported

How to modify Upgrade header

ModHeader is a Chrome extension that allows you to modify the HTTP headers sent in a request. To use it to modify the Upgrade Header:

  1. Install and open the ModHeader extension.
  2. In the Request Headers section, click 'Add'.
  3. In the left box (Name), enter 'Upgrade'.
  4. In the right box (Value), enter the protocol you're wanting to switch to, e.g., 'websocket'.

Now, whenever you make a request, it'll include this Upgrade header, proposing to switch to the specified protocol. This is particularly useful when testing server behavior under different protocols. However, not all servers will accept the upgrade request. In such cases, the server will continue to communicate using the original protocol.