Re: Location based RedirectStrategy

2017-01-16 Thread Oleg Kalnichevski
On Mon, 2017-01-16 at 13:22 +0100, Lucas Ventura Carro wrote:
> I wanted to develop an specific RedirectStrategy, which will accept
> the
> redirect based on the location URI returned in response.
> 
> So my idea was to override the 'isRedirected' method and, retrieve
> the URI
> with 'getLocationURI', decide redirection based on this value and a
> fixed
> set -- as method 'isRedirectable' doesn't fit my needs.
> 
> But when reviewing the code from
> DefaultRedirectStrategy.getLocation[1]
> I've realized that each time is called, it will store the URI in the
> current request context.
> Is this correct? Should not this be done on the caller method
> 'getRedirect'
> instead? As 'getLocation' seems more calculating, than doing the
> redirection itself.
> 
> [1]:
> https://hc.apache.org/httpcomponents-client-ga/httpclient/xref/org/ap
> ache/http/impl/client/DefaultRedirectStrategy.html#122
> 
> --
> Lucas

Hi Lucas 

You are right. #getRedirect might be a better place for circular
redirect detection logic. Feel free to raise a JIRA with a change
request or raise PR at GitHub or both.

Oleg 

-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



Location based RedirectStrategy

2017-01-16 Thread Lucas Ventura Carro
I wanted to develop an specific RedirectStrategy, which will accept the
redirect based on the location URI returned in response.

So my idea was to override the 'isRedirected' method and, retrieve the URI
with 'getLocationURI', decide redirection based on this value and a fixed
set -- as method 'isRedirectable' doesn't fit my needs.

But when reviewing the code from DefaultRedirectStrategy.getLocation[1]
I've realized that each time is called, it will store the URI in the
current request context.
Is this correct? Should not this be done on the caller method 'getRedirect'
instead? As 'getLocation' seems more calculating, than doing the
redirection itself.

[1]:
https://hc.apache.org/httpcomponents-client-ga/httpclient/xref/org/apache/http/impl/client/DefaultRedirectStrategy.html#122

--
Lucas