hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: question regarding HttpRequestInterceptor
Date Tue, 16 Mar 2010 14:17:20 GMT
On Tue, 2010-03-16 at 13:02 +0000, Carl-Gustaf Harroch wrote:
> Ok I have 2 RequestInterceptors - correct me if I am putting my logic wrongly:
> 
> 1. AddNameValuePair to the URI of the request (e.g. http://..../?token=mytoken)
> 2. Sign the request using OAuth (e.g. add oauth_token, oauth_signature
> and so forth to the header)
> 
> The first interceptor will add the token correctly but won't be seen
> by the second interceptor (as it s wrapped).

Ehhh, why is that? 

All interceptors are passed exactly the same instance of the HTTP
request. If the request object is modified by an interceptor, the
changes become visible to all subsequent interceptors in the protocol
processing chain.

Oleg

>  So the OAuth signing will
> not take into account the token value in its signing process which
> then fails the call. If I can manipulate the original request then it
> would be fine... I guess the idea is that the interceptor should not
> be interdependent and should be loosely coupled but the possibility to
> persist the wrapped request to the original should be optional.
> Especially that you can set the index of the interceptors.
> 
> Any thoughts?
> 
> ./C
> 
> On 16 March 2010 09:23, Oleg Kalnichevski <olegk@apache.org> wrote:
> > On Tue, 2010-03-16 at 00:39 +0000, Carl-Gustaf Harroch wrote:
> >> Hi again,
> >> I am trying to add a HttpRequestInterceptor. Something very simple:
> >>
> >> HttpClient client = new DefaultHttpClient();
> >> client.addRequestInterceptor(tokenInterceptor);
> >> HttpGet get = new HttpGet("http://google.com");
> >> client.execute(get);
> >>
> >> The tokenInterceptor  just print the request which is of type
> >> RequestWrapper. Is this normal behaviour?
> >
> > Yes, it is. HttpClient creates a wrapper for the original request in
> > order to ensure its immutability.
> >
> >>  How could I get the entity
> >> from a POST
> >
> > The same way as always: by testing if the object is an instance of
> > HttpEntityEnclosingRequest.
> >
> >> or change some of the original request? Getting the
> >> original request via getOriginal() will not persist any changes as far
> >> as I can tell. I am just a bit confused to how this is handled and was
> >> wondering if anybody had an example.
> >>
> >
> > Why would you want to change the original request object?
> >
> > Oleg
> >
> >
> >> Cheers,
> >> Carl
> >>
> >> ---------------------------------------------------------------------
> >> 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


Mime
View raw message