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 Warren Bell <wa...@gmail.com> on 2012/02/10 05:26:33 UTC

HttpClient in a proxy servlet

I am using HttpClient in a proxy servlet and I want to configure it so
that it does not handle redirects automatically or add any request
headers or request entities. I will be passing all request headers and
request entities to it.

What is the best way to configure HttpClient to act like a proxy ?

Thanks,

Warren Bell

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


Re: HttpClient in a proxy servlet

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2012-02-10 at 09:02 -0800, Warren Bell wrote:
> Oleg,
> 
> So I should extend AbstractHttpClient, and if so can I get away with
> adding no params and adding a bare minimum of interceptors and what
> interceptors do I absolutely have to include ?
> 
> Thanks,
> 

Required protocol interceptors
* RequestContent
* RequestTargetHost
Recommended:
* RequestClientConnControl
* RequestExpectContinue

Hope this helps,

Oleg


> Warren Bell
> 
> On 2/10/12 8:56 AM, Oleg Kalnichevski wrote:
> > On Fri, 2012-02-10 at 08:50 -0800, Warren Bell wrote:
> >> Oleg,
> >>
> >> I am looking at the source code for DefaultHttpClient and thinking that
> >> I should just extend AbstractHttpClient myself and configure it in a
> >> striped down version. I see the two methods
> >> setDefaultHttpParams(HttpParams params) and createHttpProcessor() and
> >> that these methods are adding params and interceptors.
> >>
> >> Can I write a version of setDefaultHttpParams(HttpParams params) that
> >> does not add any parameters and relies only on the parameters I add to
> >> the request ?
> >>
> >> Can I overide createHttpProcessor() and just add the bare minimum of
> >> interceptors needed, and if so what interceptors should I include ?
> >>
> >> Or, am I going about this the wrong way completely. I am counting on the
> >> client's browser in front of my proxy to get the request correct. I just
> >> want to pass the request on to HttpClient the way it came from the
> >> client's browser.
> >>
> > 
> > This is absolutely the right way.
> > 
> > Oleg
> > 
> >>
> >> Thanks,
> >>
> >> Warren Bell
> >>
> >> On 2/10/12 3:05 AM, Oleg Kalnichevski wrote:
> >>> On Thu, 2012-02-09 at 20:26 -0800, Warren Bell wrote:
> >>>> I am using HttpClient in a proxy servlet and I want to configure it so
> >>>> that it does not handle redirects automatically or add any request
> >>>> headers or request entities. I will be passing all request headers and
> >>>> request entities to it.
> >>>>
> >>>> What is the best way to configure HttpClient to act like a proxy ?
> >>>>
> >>>> Thanks,
> >>>>
> >>>> Warren Bell
> >>>>
> >>>
> >>> You should certainly want to disable automatic redirect handling. You
> >>> might as well disable authentication and cookie management.
> >>>
> >>> Hope this helps
> >>>
> >>> Oleg 
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >>
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 



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


Re: HttpClient in a proxy servlet

Posted by Warren Bell <wa...@gmail.com>.
Oleg,

So I should extend AbstractHttpClient, and if so can I get away with
adding no params and adding a bare minimum of interceptors and what
interceptors do I absolutely have to include ?

Thanks,

Warren Bell

On 2/10/12 8:56 AM, Oleg Kalnichevski wrote:
> On Fri, 2012-02-10 at 08:50 -0800, Warren Bell wrote:
>> Oleg,
>>
>> I am looking at the source code for DefaultHttpClient and thinking that
>> I should just extend AbstractHttpClient myself and configure it in a
>> striped down version. I see the two methods
>> setDefaultHttpParams(HttpParams params) and createHttpProcessor() and
>> that these methods are adding params and interceptors.
>>
>> Can I write a version of setDefaultHttpParams(HttpParams params) that
>> does not add any parameters and relies only on the parameters I add to
>> the request ?
>>
>> Can I overide createHttpProcessor() and just add the bare minimum of
>> interceptors needed, and if so what interceptors should I include ?
>>
>> Or, am I going about this the wrong way completely. I am counting on the
>> client's browser in front of my proxy to get the request correct. I just
>> want to pass the request on to HttpClient the way it came from the
>> client's browser.
>>
> 
> This is absolutely the right way.
> 
> Oleg
> 
>>
>> Thanks,
>>
>> Warren Bell
>>
>> On 2/10/12 3:05 AM, Oleg Kalnichevski wrote:
>>> On Thu, 2012-02-09 at 20:26 -0800, Warren Bell wrote:
>>>> I am using HttpClient in a proxy servlet and I want to configure it so
>>>> that it does not handle redirects automatically or add any request
>>>> headers or request entities. I will be passing all request headers and
>>>> request entities to it.
>>>>
>>>> What is the best way to configure HttpClient to act like a proxy ?
>>>>
>>>> Thanks,
>>>>
>>>> Warren Bell
>>>>
>>>
>>> You should certainly want to disable automatic redirect handling. You
>>> might as well disable authentication and cookie management.
>>>
>>> Hope this helps
>>>
>>> Oleg 
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 

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


Re: HttpClient in a proxy servlet

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2012-02-10 at 08:50 -0800, Warren Bell wrote:
> Oleg,
> 
> I am looking at the source code for DefaultHttpClient and thinking that
> I should just extend AbstractHttpClient myself and configure it in a
> striped down version. I see the two methods
> setDefaultHttpParams(HttpParams params) and createHttpProcessor() and
> that these methods are adding params and interceptors.
> 
> Can I write a version of setDefaultHttpParams(HttpParams params) that
> does not add any parameters and relies only on the parameters I add to
> the request ?
> 
> Can I overide createHttpProcessor() and just add the bare minimum of
> interceptors needed, and if so what interceptors should I include ?
> 
> Or, am I going about this the wrong way completely. I am counting on the
> client's browser in front of my proxy to get the request correct. I just
> want to pass the request on to HttpClient the way it came from the
> client's browser.
> 

This is absolutely the right way.

Oleg

> 
> Thanks,
> 
> Warren Bell
> 
> On 2/10/12 3:05 AM, Oleg Kalnichevski wrote:
> > On Thu, 2012-02-09 at 20:26 -0800, Warren Bell wrote:
> >> I am using HttpClient in a proxy servlet and I want to configure it so
> >> that it does not handle redirects automatically or add any request
> >> headers or request entities. I will be passing all request headers and
> >> request entities to it.
> >>
> >> What is the best way to configure HttpClient to act like a proxy ?
> >>
> >> Thanks,
> >>
> >> Warren Bell
> >>
> > 
> > You should certainly want to disable automatic redirect handling. You
> > might as well disable authentication and cookie management.
> > 
> > Hope this helps
> > 
> > Oleg 
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 



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


Re: HttpClient in a proxy servlet

Posted by Warren Bell <wa...@gmail.com>.
Oleg,

I am looking at the source code for DefaultHttpClient and thinking that
I should just extend AbstractHttpClient myself and configure it in a
striped down version. I see the two methods
setDefaultHttpParams(HttpParams params) and createHttpProcessor() and
that these methods are adding params and interceptors.

Can I write a version of setDefaultHttpParams(HttpParams params) that
does not add any parameters and relies only on the parameters I add to
the request ?

Can I overide createHttpProcessor() and just add the bare minimum of
interceptors needed, and if so what interceptors should I include ?

Or, am I going about this the wrong way completely. I am counting on the
client's browser in front of my proxy to get the request correct. I just
want to pass the request on to HttpClient the way it came from the
client's browser.


Thanks,

Warren Bell

On 2/10/12 3:05 AM, Oleg Kalnichevski wrote:
> On Thu, 2012-02-09 at 20:26 -0800, Warren Bell wrote:
>> I am using HttpClient in a proxy servlet and I want to configure it so
>> that it does not handle redirects automatically or add any request
>> headers or request entities. I will be passing all request headers and
>> request entities to it.
>>
>> What is the best way to configure HttpClient to act like a proxy ?
>>
>> Thanks,
>>
>> Warren Bell
>>
> 
> You should certainly want to disable automatic redirect handling. You
> might as well disable authentication and cookie management.
> 
> Hope this helps
> 
> Oleg 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 

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


Re: HttpClient in a proxy servlet

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2012-02-09 at 20:26 -0800, Warren Bell wrote:
> I am using HttpClient in a proxy servlet and I want to configure it so
> that it does not handle redirects automatically or add any request
> headers or request entities. I will be passing all request headers and
> request entities to it.
> 
> What is the best way to configure HttpClient to act like a proxy ?
> 
> Thanks,
> 
> Warren Bell
> 

You should certainly want to disable automatic redirect handling. You
might as well disable authentication and cookie management.

Hope this helps

Oleg 



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