代码为3xx且空“位置”标头的HTTP响应 [英] HTTP responses with code 3xx and empty 'Location' header

查看:143
本文介绍了代码为3xx且空“位置”标头的HTTP响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Java连接到URL( HttpURLConnection )。

I'm connecting to URLs with Java (HttpURLConnection).

我注意到在某些情况下,响应代码为3xx,但位置标题为空。

I have noticed that in some cases, the response code is 3xx but the 'Location' header is empty.

客户端浏览器在收到此类HTTP响应后如何知道重定向的位置?

How does a client browser know where to redirect after receiving this kind of HTTP response?

谢谢

推荐答案

并非所有 3xx 回复可以自动重定向。

Not all 3xx replies can redirect automatically.

300 在响应正文中提供多个网址,而不是位置标头。客户/用户必须决定接下来要检索哪一个。

300 provides multiple URLs in the response body, not in the Location header. The client/user has to decide which one to retrieve next.

301 302 303 307 提供位置仅在知道下一个URL时。否则,客户/用户必须决定下一步该做什么。

301, 302, 303, and 307 provide a Location only if the next URL is known. Otherwise, the client/user has to decide what to do next.

304 不是重定向。它是对条件GET的响应,其中请求的内容自上次满足请求的条件以来未发生更改。

304 is not a redirect. It is a response to a conditional GET, where the requested content has not changed since the requested criteria was last satisfied.

305 始终向所需的代理提供位置以进行连接。

305 always provides a Location to the required proxy to connect to.

306 已不再使用。

这篇关于代码为3xx且空“位置”标头的HTTP响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆