开发者

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

开发者 https://www.devze.com 2023-02-04 10:48 出处:网络
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 req

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?


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消