What Is a 101 Status Code?
The server understands and is willing to comply with the client’s request, via the Upgrade header field 1, for a change in the application protocol being used on this connection.
The server MUST generate an Upgrade header field in the response that indicates which protocol(s) will be switched to immediately after the empty line that terminates the 101 response.
It is assumed that the server will only agree to switch protocols when it is advantageous to do so. For example, switching to a newer version of HTTP might be advantageous over older versions, and switching to a real-time, synchronous protocol might be advantageous when delivering resources that use such features.
- 1 Upgrade RFC7230 Section 6.7
- Source: RFC7231 Section 6.2.2
101 CODE REFERENCES
Rails HTTP Status Symbol :switching_protocols
Go HTTP Status Constant http.StatusSwitchingProtocols
Symfony HTTP Status Constant Response::HTTP_SWITCHING_PROTOCOLS
Python2 HTTP Status Constant httplib.SWITCHING_PROTOCOLS
Python3+ HTTP Status Constant http.client.SWITCHING_PROTOCOLS
Python3.5+ HTTP Status Constant http.HTTPStatus.SWITCHING_PROTOCOLS
.NET HttpStatusCode.SwitchingProtocols
Rust http::StatusCode::SWITCHING_PROTOCOLS
Apache HttpComponentsCore org.apache.hc.core5.http.HttpStatus.SC_SWITCHING_PROTOCOLS
Angular @angular/common/http/HttpStatusCode.SwitchingProtocols
101 status code example
Here is an example of a request and response for a 101 status code:
Request
GET /example HTTP/1.1
Host: www.example.com
Connection: Upgrade
Upgrade: TLS/1.2
Response
HTTP/1.1 101 Switching Protocols
Upgrade: TLS/1.2
Connection: Upgrade
In this example, the client is requesting the /example resource from www.example.com using the HTTP/1.1 protocol. The client also requests to upgrade the protocol to TLS/1.2.
The server responds with a 101 status code, which indicates that the server is switching protocols as requested by the client. The server also includes the “Upgrade” and “Connection” headers to indicate that the protocol has been upgraded to TLS/1.2.
When should you use a 101 status code?
The 101 status code, “Switching Protocols,” should be used when the server receives a request that includes an “Upgrade” header indicating a protocol change. It indicates that the server is switching to the new protocol as requested by the client.
This status code is commonly used in WebSocket connections, where the initial request is an HTTP request to upgrade the connection to the WebSocket protocol. The server responds with a 101 status code and switches to the WebSocket protocol.
What are 1xx status codes?
The 1xx status codes are used to indicate informational messages about the request or response, and there are several different 100 status codes defined in the HTTP/1.1 specification, including:
- 100 Continue
- 101 Switching Protocols
- 102 Processing
- 103 Early Hints
The “100 Continue” status code is used to indicate that the client should continue sending the request body to the server. This is typically used when the request has a large body that is being sent in multiple parts, and the server wants to acknowledge receipt of each part.
Additional resources
- Learn about web development
- Learn about SEO
- Web development services from WebFX
- SEO services from WebFX
- MDN Web Docs
- W3Schools
Marketing Tips for Niche Industries
- Trucking Website Design Services That Help You Grow Online
- Web Design for PPE Companies: 5 Sales-Boosting Design Tips
- Web Design for Exercise Equipment Companies: Browse Services & Get Tips
- Web Design for Storage Facilities: Launch a Revenue-Driving Site
- Web Design for Pressure Washing Companies
- Web Design for Restoration Companies (+4 Tips for Success)
- Web Design for Flooring Companies – WebFX Design Services
- Web Design for Biotech Companies: How to Design a Biotech Site
- Web Design for Window and Door Companies: Inspire Your Site