101

Switching Protocols

1xx Informational

Back to list

Server perspective

Use 101 when the client requested a protocol upgrade and the server is switching this connection to that protocol.

When to use

  • Return 101 for successful WebSocket upgrades
  • Use it only when the protocol switch is explicitly requested and supported

How to respond

  • Include Upgrade and Connection: Upgrade in the successful response
  • Start speaking the new protocol immediately after the 101 response

Headers to consider

  • Upgrade
  • Connection

Response body

  • Do not include a response body in a 101 response

Server-side pitfalls

  • Do not use 101 unless the client actually requested an upgrade
  • Do not treat 101 as a redirect or as a generic signal to retry elsewhere

Examples

Server upgrades to WebSocket

Request:GET /socket with Upgrade: websocket
Response:101 Switching Protocols with Connection: Upgrade

The server confirms the switch and the connection leaves ordinary HTTP messaging behind.

References

Related 1xx Informational Codes