On Wed, 2012-07-25 at 16:43 +0200, Leo Galambos wrote: > For instance, there is not an alternative for > NHttpRequestExecutionHandler::responseEntity method in > HttpAsyncRequester/HttpAsyncRequestExecutor, I guess. How/where can I > monitor the length of incoming data stream to cancel it as soon as it is > too long? > > Thank you, > LG
One can exert full control over incoming response messages by using a custom HttpAsyncResponseConsumer implementation. http://hc.apache.org/httpcomponents-core-ga/httpcore-nio/apidocs/org/apache/http/nio/protocol/HttpAsyncResponseConsumer.html http://hc.apache.org/httpcomponents-core-ga/tutorial/html/nio.html#d5e1151 Hope this helps Oleg > On 07/23/2012 03:29 PM, William Speirs wrote: > > Where are you getting stuck? Most of the documentation specifies the > > new class/interface to use for deprecated classes/interfaces. For > > example, NHttpClientHandler is deprecated in favor of > > NHttpClientEventHandler. > > > > If you have a more specific question about how to accomplish something > > with the new API someone can probably answer that question. > > > > Bill- > > > > On Sat, Jul 21, 2012 at 3:54 PM, Leo Galambos <[email protected]> wrote: > >> Hello, > >> > >> I have just decided to migrate my project from API 4.0 to 4.2. There is > >> a lot of new stuff, so I am not sure what's the best way to > >> (re)implement the following logic. Can you enlighten me, please? Thank you! > >> > >> Short story: I need to > >> a) assign some initial values for HTTP requests, > >> b) process the HTTP responses with respective callbacks, and > >> c) cancel a request when it produces a long response data stream. > >> > >> Current (4.0 API) implementation: The application uses > >> NHttpClientHandler as a wrapper for NHttpRequestExecutionHandler. This > >> execution handler (exec-handler) assigns some starting values, e.g. > >> user-agent and target-host, according to an attachment object in > >> initalizeContext(). The handler also constructs a special entity (see > >> responseEntity method) that throws an exception when the data stream is > >> too long. The exception is caught and handled in an event listener (see > >> EventListener interface) registered in the client-handler (see > >> setEventListener). Finally, the body of the response is processed (see > >> exec-handler's handleResponse method) by a callback stored in the > >> context object. > >> > >> LG > >> > >> BTW: Obviously, I can share the source code. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
