java.net.http.HttpClient Redirect Policy
Daniel Fuchs
daniel.fuchs at oracle.com
Fri Oct 18 16:38:19 UTC 2019
Hi Eliot,
On 04/10/2019 22:13, Elliot Barlas wrote:
> Why is HttpClient behaving this way? Browsers certainly doin't do this.
> Am I missing a config option?
Thanks for reporting this. I believe this is a bug - I have logged
https://bugs.openjdk.java.net/browse/JDK-8232625
In the mean time - I'd suggest simply not setting any redirect
policy in the HttpClient, and handling the redirect directly from
your application code instead.
e.g. something like:
HttpResponse<String> resp = client.send(...);
if (resp.statusCode() == 303) {
String location = resp.headers().firstValue("Location")
.orElseThrows(....)
resp = client.send(...)
}
best regards,
-- daniel
More information about the net-dev
mailing list