101 Switching Protocols
HTTP response status code 101 Switching Protocols is an informational HTTP response returned by the server. It indicates that the HTTP session can continue and the server is switching to a new protocol. This response is sent when the client includes the HTTP header request field Upgrade, as well as the HTTP request header field
Connection: upgrade , which is a mandatory HTTP request header.
Clients that include the Upgrade request header field want the server to use a different protocol for the remainder of the HTTP session. Multiple HTTP protocols can be listed on a single line, comma-delimited, in order of descending preference. The HTTP protocol version is optional.
Connection: upgrade Upgrade: protocol-name[/protocol-version]
The HTTP request will be made when there is a benefit to doing so, such as taking advantage of features offered by more recent versions of the HTTP protocol. Currently this upgrade is only supported by HTTP/1.1 and a client cannot force the server to change HTTP protocols. Rather, it is optional, and the server will return a 200 OK response if the Upgrade header request field was ignored.
Although the server cannot force a client to upgrade HTTP protocols, it can refuse HTTP requests if a client fails to meet its requirements. When a client makes a HTTP request using a HTTP protocol that the server does not support, the server may return the status code 426 Upgrade Required. Using the HTTP protocol as directed by the server, the client may have subsequent HTTP requests accepted and processed.
Upgrade from HTTP/1.1 to HTTP/2 or HTTP/3
GET /index.html HTTP/1.1 Host: www.example.re Connection: upgrade Upgrade: HTTP/3, HTTP/2
HTTP/1.1 101 Switching Protocols Upgrade: HTTP/2 Connection: upgrade
Upgrade from HTTP/1.1 to use WebSockets
GET /index.html HTTP/1.1 Host: www.example.re Connection: upgrade Upgrade: websocket
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: upgrade
Apache HttpComponents Core
The 101 Switching Protocols informational response status code is sent by the server to inform the client that the HTTP protocol in the HTTP session is switching, as requested, and the new HTTP protocol is specified.