305 HTTP 状态代码是什么?如何正确使用呢?

发布于 2024-10-12 02:24:46 字数 137 浏览 3 评论 0原文

我发现:“所请求的资源必须通过 Location 字段给出的代理进行访问。Location 字段给出了代理的 URI。接收者应该通过代理重复这个单个请求。305 响应必须只能由原始服务器。”

如何正确使用呢?如果给定 URL 下没有代理怎么办?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

很糊涂小朋友 2024-10-19 02:24:46

它是一个重定向,当您想告诉客户端从其他地方获取内容时可以使用它。给定的 URI 不一定是该词口语中的“代理”。它只是最初请求的内容存在的另一个地方。

人们用它来实现负载平衡。我不确定哪些客户端可以正确实现它,因此如果您只想重定向,那么使用 302 会更安全。

编辑

预期的使用示例,如 HTTP RFC 中所述:假设您有一个缓存代理,其上的内容来自真实服务器(源服务器)。如果有人以某种方式直接访问真实服务器,并且您希望他们从代理获取它,您会发送 305。

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.

源来凯始玺欢你 2024-10-19 02:24:46

很少使用的代码,如果客户端作为通信链中的代理,服务器是否允许发送它?也许不是,但是检测代理很困难。如果服务器后面有一个反向代理,该代理会接受 305 错误并将其转发给 HTTP 客户端吗?

通常是为了重定向应该使用安全代理访问的“直接访问”,问题是为什么可以使用直接访问?肯定是之前的安全链出了问题。

那么谁关心在服务器端使用 305 呢?我希望您不要尝试生成 305 响应。

如果您是 HTTP 客户端,它只是像 302 这样的重定向,您不需要知道您是否正在与代理通信(有时很难知道)。

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

稀香 2024-10-19 02:24:46

305状态码指的是“305使用代理”。该状态码用于指示所请求的资源必须通过指定的代理服务器访问。服务器使用此代码以及响应中代理的位置信息进行响应,指示客户端使用代理进行进一步的请求。

然而,由于安全问题和不够具体,它已被弃用。它没有说明为什么使用代理,或者是否需要它。

替代方案

您可以使用更具体的状态代码,而不是使用 305 状态代码,例如:

  • 302 Found
  • 307 Temporary Redirect

The 305 status code refers to "305 Use Proxy". This status code was used to indicate that the requested resource must be accessed through a specified proxy server. The server responds with this code along with the proxy's location information in the response, instructing the client to use the proxy for further requests.

However, it was deprecated due to security concerns and because it was not very specific. It didn't say why the proxy was being used, or whether it was even required.

Alternatives

Instead of using the 305 status code, you can use a more specific status code, such as:

  • 302 Found
  • 307 Temporary Redirect
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文