Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's 305 HTTP status code? How to use it properly?

All I found: "The requested resource MUST be accessed through the proxy given by the Location field. The Location field gives the URI of the proxy. The recipient is expected to repeat this single request via the proxy. 305 responses MUST only be generated by origin servers."

How to use it properly? What if there's no proxy under given URL?

like image 413
Sarah Avatar asked Dec 22 '22 19:12

Sarah


2 Answers

Its a redirect, you use it when you want to tell a client to get the content from somewhere else. The URI given doesn't have to be a 'proxy' in the colloquial use of the word. It it just another place where the originally requested content exists.

People use it for load balancing. I'm not sure what clients implement it properly, so if you just want to redirect, you'll be safer going with a 302.

Edit

The intended use example, as described in HTTP RFC: Say you have a caching proxy, and the content on it comes from the real server (the origin server). You'd send a 305 if someone somehow directly accessed the real server, and you wanted them to get it from the proxy instead.

like image 100
profitphp Avatar answered Dec 28 '22 05:12

profitphp


Rarely used code, is the server allowed to send it if the client as a proxy in the chain of communication? maybe not, but detecting a proxy is hard. If there's a reverse proxy just after the server, will this proxy accept a 305 error and forwrd it to the HTTP client?

It's normally done to redirect a 'direct access' which should use a secure proxy access, and the question is why a direct access is available? Certainly something wrong in the security chain before.

So who cares using 305 in the server side? I hope you're not trying to generate a 305 response.

If you're the HTTP client it's just a redirect like a 302, you don't need to know if you're talking to a proxy or not (and it would be hard to know it sometimes).

like image 38
regilero Avatar answered Dec 28 '22 07:12

regilero