The HTTP Status Code 306 Switch Proxy
is a rare and obsolete status code that was used in the past to indicate that the requested resource must be accessed through the proxy mentioned in the Location
header. This status code is no longer used, and there is no direct replacement for it in the current HTTP/1.1 specification (RFC 7231).
Background
The 306 Switch Proxy
status code was defined in the early drafts of the HTTP/1.1 specification but was later removed due to security concerns and lack of practical use cases. The idea behind this status code was to allow a server to instruct the client to switch to a different proxy for future requests, but this functionality can now be achieved through other means, such as the 305 Use Proxy
status code and the Proxy
header.
Usage
Since the 306 Switch Proxy
status code is now obsolete, it is not recommended to use it in modern applications. However, for historical reference and understanding, here’s an example of how it might have been used in a request and response:
Request
GET /example HTTP/1.1
Host: www.example.com
Response
HTTP/1.1 306 Switch Proxy
Location: http://proxy.example.org:8080/
Content-Type: text/html
Content-Length: 178
<!DOCTYPE html>
<html>
<head>
<title>Switch Proxy</title>
</head>
<body>
<p>Please use the proxy at <a href="http://proxy.example.org:8080/">http://proxy.example.org:8080/</a> for future requests.</p>
</body>
</html>
In this example, the server responds with a 306 Switch Proxy
status code and a Location
header pointing to the new proxy. The client would then be expected to use this proxy for future requests. However, as previously mentioned, this status code is now obsolete and should not be used in modern applications.
Alternatives
For modern applications, there are alternative methods to achieve similar functionality. The 305 Use Proxy
status code can be used to instruct the client to use a specific proxy for the requested resource. Additionally, the Proxy
header can be used to specify the proxy server that the client should use for the request.
Example with 305 Use Proxy
Request
GET /example HTTP/1.1
Host: www.example.com
Response
HTTP/1.1 305 Use Proxy
Location: http://proxy.example.org:8080/
Content-Type: text/html
Content-Length: 178
<!DOCTYPE html>
<html>
<head>
<title>Use Proxy</title>
</head>
<body>
<p>Please use the proxy at <a href="http://proxy.example.org:8080/">http://proxy.example.org:8080/</a> to access the requested resource.</p>
</body>
</html>
In this example, the server responds with a 305 Use Proxy
status code and a Location
header pointing to the proxy that should be used to access the requested resource.
Summary
The 306 Switch Proxy
status code is an obsolete and unused status code that was intended to instruct the client to switch to a different proxy for future requests. It has been removed from the HTTP/1.1 specification due to security concerns and lack of practical use cases. Instead, modern applications should use the 305 Use Proxy
status code and the Proxy
header to achieve similar functionality.