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 Chris Krahe <ck...@gmail.com> on 2012/05/03 19:37:59 UTC

handle-redirects with listener

Perhaps I'm lazy, but I'm wondering if there's a way (or could be a way) to
attach a listener to the HttpClient such that all redirects are first
passed to the listener before they're submitted.  The listener would have
the opportunity to inspect the proposed request (e.g. GET) and, if desired,
reject it.

I'll state the obvious:

   1. This sounds like the job of a forward proxy
   2. Alternatively, the code could disable automatic redirects and handle
   them itself

But like I said, perhaps I'm lazy.  Configuring a forward proxy, like
Squid, is non-trivial.  Handling redirects manually is non-trivial.

Thoughts?
Chris

Re: handle-redirects with listener

Posted by Chris Krahe <ck...@gmail.com>.
Nothing at all.  My apologies for not reading & searching thoroughly enough.

On Thu, May 3, 2012 at 2:48 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Thu, 2012-05-03 at 13:37 -0400, Chris Krahe wrote:
> > Perhaps I'm lazy, but I'm wondering if there's a way (or could be a way)
> to
> > attach a listener to the HttpClient such that all redirects are first
> > passed to the listener before they're submitted.  The listener would have
> > the opportunity to inspect the proposed request (e.g. GET) and, if
> desired,
> > reject it.
> >
> > I'll state the obvious:
> >
> >    1. This sounds like the job of a forward proxy
> >    2. Alternatively, the code could disable automatic redirects and
> handle
> >    them itself
> >
> > But like I said, perhaps I'm lazy.  Configuring a forward proxy, like
> > Squid, is non-trivial.  Handling redirects manually is non-trivial.
> >
> > Thoughts?
> > Chris
>
> What is wrong with the RedirectStrategy?
>
>
> http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/RedirectStrategy.html
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: handle-redirects with listener

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2012-05-03 at 13:37 -0400, Chris Krahe wrote:
> Perhaps I'm lazy, but I'm wondering if there's a way (or could be a way) to
> attach a listener to the HttpClient such that all redirects are first
> passed to the listener before they're submitted.  The listener would have
> the opportunity to inspect the proposed request (e.g. GET) and, if desired,
> reject it.
> 
> I'll state the obvious:
> 
>    1. This sounds like the job of a forward proxy
>    2. Alternatively, the code could disable automatic redirects and handle
>    them itself
> 
> But like I said, perhaps I'm lazy.  Configuring a forward proxy, like
> Squid, is non-trivial.  Handling redirects manually is non-trivial.
> 
> Thoughts?
> Chris

What is wrong with the RedirectStrategy?

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/RedirectStrategy.html

Oleg


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