Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP responses with code 3xx and empty 'Location' header

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

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

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

Thanks

like image 222
barak manos Avatar asked Jul 21 '26 04:07

barak manos


1 Answers

Not all 3xx replies can redirect automatically.

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, and 307 provide a Location only if the next URL is known. Otherwise, the client/user has to decide what to do next.

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 always provides a Location to the required proxy to connect to.

306 is not used anymore.

like image 139
Remy Lebeau Avatar answered Jul 22 '26 19:07

Remy Lebeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!