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.
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.
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
A typical example would be upgrading HTTP to WebSocket:
Or for a HTTP/2 upgrade:
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:
- Install and open the ModHeader extension.
- In the Request Headers section, click 'Add'.
- In the left box (Name), enter 'Upgrade'.
- 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.