On Tue, 2015-07-28 at 20:45 +0800, Cap zhou wrote: > Hi: > > I want to close the underlying connection if the status code of response is > not 2XX, or I don't want the connection to be reused if any request on it > has ever failed. how? I am using httpasyncclient 4.0.2. > > why I want to do this? Because in some situations my server may return > error right after it finished receiving the http headers while the body is > not completed. And the client may stop sending body if it receive the > response. And if the connection is reused by another request, the data of > http header of the new request may consider to be the rest body data of the > last request. Then the second request will fail with an unexpected > exception. > > My solution to this problem is: don't reuse the connection if any request > has failed it.
Use a custom response consume and throw an exception from any of its methods. That will lead to termination of the current session and the underlying connection. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
