3xx HTTP responses and a blank Location header

I am connecting to urls with Java ( HttpURLConnection ).

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

How does the client browser know where to redirect after receiving such an HTTP response?

thanks

+1
source share
2 answers

Not all 3xx responses can be automatically redirected.

300 contains multiple URLs in the response body, not in the Location header. The client / user must decide which one should be obtained next.

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

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

305 always provides Location required proxy for connection.

306 no longer in use.

+3
source

If you look at the HTTP specification for some of the 3xx status codes, some of them MUST only provide a Location header.

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

This is not true. In this case, the client must process what needs to be done.

+1
source

All Articles