jersey icon indicating copy to clipboard operation
jersey copied to clipboard

Make ApacheConnector more open for extension or provide access to ClientResponse#getResolvedRequestUri()

Open rgacki opened this issue 8 years ago • 0 comments

Hi,

I am trying to use the client to write against a REST API. The API is navigable and I need to resolve URLs for new requests based on the URL of previous responses (e.g. if a relative URI is returned in a response). In order to make this work, I need to get the actual URL from the response. Since Jersey supports HTTP clients that can follow redirects, I cannot use the initial URL of the request.

Unfortunately, there is no way to access Jersey‘s ClientResponse#getResolvedRequestUri() method, at least not without forcing access to the instance within the Response implementation.

In my current project, I use the Apache HTTP Client and Jersey‘s ApacheConnector. So, I also looked into writing a HttpResponseInterceptor which could add the effective URL as a header. This method would be elegant. But the ApacheConnector is closed for extension. I am not able to extend the configuration of the HttpClient (via HttpClientBuilder).

So it would be helpful, if the connector is more open for modification. If my problem can be solved in a different way, I‘d appreciate any advice.

For now, I will probably write a custom connector, since I don‘t want to handle redirects manually through the JAX-WS RS API.

Thanks, Robert

rgacki avatar Jan 24 '18 18:01 rgacki