user2684301
user2684301

Reputation: 2620

How do I get response URI from a Jersey web response?

If I do:

    Response response = webTarget.request().get();
    URI redirectUri = response.getLocation();

response.getLocation() will be null if Jersey does not need to follow a redirect or automatically follows a redirect.

Only for manual, non automatic redirects will response.getLocation() be non-null.

How do I tell if the Jersey Response followed an automatic redirect? How do I get that URL?

Upvotes: 2

Views: 652

Answers (1)

Will
Will

Reputation: 6711

If this is only for debugging purposes, you could register the LoggingFilter with your client which should give you the request / response cycles.

webTarget.register(new LoggingFilter())

If you need to know this in production I think you'll have to handle the redirects yourself. I might be wrong, but I can't see a way to get request history from the client (unless you tracked it yourself of course).

Hope this helps.

Will

Upvotes: 1

Related Questions