Re: Intercepting and responding to requests on client-side

2013-06-02 Thread Marko Asplund
Oleg wrote:

> Please upgrade to 4.3 and have a look at the new execution chain APIs.
> You can use the caching exec as an example of how HttpClient can be made
> to respond with a response without hitting the target server.

thanks Oleg!

I did some experimenting earlier with HC 4.2 using the following approach:
- create a custom HttpClient subclass with overridden
createRequestExecutor() method
- make createRequestExecutor() return a custom HttpRequestExecutor
with overridded execute() method

I noticed that one problem with this approach was that I'm not able to
intercept redirected requests.
HC seems to be using DefaultRequestDirector for executing the
redirected requests instead of the custom executor.

Does using the new executions chain APIs solve this issue?


marko

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



Re: Intercepting and responding to requests on client-side

2013-06-02 Thread Oleg Kalnichevski
On Sun, 2013-06-02 at 11:21 +0300, Marko Asplund wrote:
> Oleg wrote:
> 
> > Please upgrade to 4.3 and have a look at the new execution chain APIs.
> > You can use the caching exec as an example of how HttpClient can be made
> > to respond with a response without hitting the target server.
> 
> thanks Oleg!
> 
> I did some experimenting earlier with HC 4.2 using the following approach:
> - create a custom HttpClient subclass with overridden
> createRequestExecutor() method
> - make createRequestExecutor() return a custom HttpRequestExecutor
> with overridded execute() method
> 
> I noticed that one problem with this approach was that I'm not able to
> intercept redirected requests.
> HC seems to be using DefaultRequestDirector for executing the
> redirected requests instead of the custom executor.
> 
> Does using the new executions chain APIs solve this issue?
> 
> 

It should.

Oleg



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



Re: Intercepting and responding to requests on client-side

2013-06-02 Thread Marko Asplund
Oleg wrote:

> Marko wrote:
> > I noticed that one problem with this approach was that I'm not able to
> > intercept redirected requests.
> > HC seems to be using DefaultRequestDirector for executing the
> > redirected requests instead of the custom executor.
> >
> > Does using the new executions chain APIs solve this issue?
>
> It should.

ok. I did some experimenting with this using HC 4.3b1, and it does
appear to work.
My proto code is available here:

https://github.com/marko-asplund/tech-protos/blob/master/hc-proto/src/main/java/fi/markoa/proto/hc/RequestInterceptionDemo.java

Is this the correct way to use the new API?

Are any big changes expected in HC 4.3 beta before the final release?
Any estimates for HC 4.3 final release date?

As a side note, try-with-resources doesn't seem to work well with a
set of related resources some of which implement AutoCloseable and
some that don't. For example it doesn't seem to be practical to use
try-with-resources with CloseableHttpClient, CloseableHttpResponse and
HttpEntity, because if the first two would be closed automatically
while the last one would be closed in a finally block, the resources
would be closed in an incorrect order.

marko

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