You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Lucas Ventura Carro <us...@gmail.com> on 2017/01/16 12:22:43 UTC

Location based RedirectStrategy

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

Re: Location based RedirectStrategy

Posted by Oleg Kalnichevski <ol...@apache.org>.
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-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org