HTTPupgrademehhanismi
The HTTP Upgrade mechanism is a feature of the Hypertext Transfer Protocol that allows a client and server to switch to a different protocol. This is typically used when the client wants to establish a connection using a protocol other than the one that was initially negotiated. The process begins with a standard HTTP request from the client to the server. This request includes an "Upgrade" header field, which specifies the desired protocol, such as "websocket" or "h2c" (for HTTP/2 without TLS). The server, if it supports the requested protocol, responds with a 101 Switching Protocols status code. This response also includes an "Upgrade" header confirming the protocol switch and an "Connection" header with the value "Upgrade" to indicate that the connection should be maintained for the new protocol. Once the 101 response is received, the client and server can begin communicating using the upgraded protocol. This mechanism is fundamental to protocols like WebSockets, which provide a persistent, full-duplex communication channel over a single TCP connection, and allows for the negotiation of newer HTTP versions like HTTP/2.