On Fri, 2012-07-06 at 11:11 +0400, Dmitry Potapov wrote: > On Fri, Jul 6, 2012 at 1:30 AM, Oleg Kalnichevski <[email protected]> wrote: > > On Thu, 2012-07-05 at 22:25 +0400, Dmitry Potapov wrote: > >> Hello everyone, > >> > >> I develop streaming HTTP server for my project and used HttpCore NIO > >> for this purpose. > >> Interruptible heavy-weight task takes place before streaming start, > >> so, I'm interesting in any mechanism that provides connection status > >> check, because I have tons of requests which terminates connection > >> before I start streaming. > >> APIs I've already tried: > >> > >> 1. HttpAsyncExchange.setCallback() — doesn't work, cancel() function > >> of the registered callback was never called. Doesn't matter how > >> connection was terminated, with RST or FIN. > > > > Dmitry > > > > There is a test case specifically intended to test Cancellable callback > > for HTTP exchanges > > > > https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.2.x/httpcore-nio/src/test/java/org/apache/http/nio/integration/TestHttpAsyncHandlerCancellable.java > This was a first file I've read before implementing my own Cancellable. > > > > > If this functionality is broken I would like to know how the problem can > > be reproduced. > > I've prepared complete test for this. > Source code and output are placed on github: https://gist.github.com/3058489 > It can be compiler and run using: > javac -cp lib/httpcore-4.2.1.jar:lib/httpcore-nio-4.2.1.jar HttpServer.java > java -cp lib/httpcore-4.2.1.jar:lib/httpcore-nio-4.2.1.jar:. HttpServer > > Test structure: > 1. Create async server with DefaultListeningIOReactor and start it in > separate thread > 2. Sleep for 1 second > 3. Send request as it done in TestHttpAsyncHandlerCancellable.java > 4. Close request socket > > What is done in request handler: > 1. Set chunked input stream entity in response object. > 1.a. InputStreamEntiry is created on top of PipedInputStream, which > corresponing PipedOutputStream will be passed to worker thread in step > 4. > 2. Set callback for the HttpAsyncExchange. Callback will be passed to > worker thread in step 4. > 3. Submit basic async response producer > 4. Start separate thread which will do some work and then produce output > 4.a. (Heavy-weight task emulation) Three times check if connection is > still alive and wait 1 second > 4.b. (Heave-weight output emulation) Three times check if connection > is still alive and write response chunk > 4.c. Close output stream, which causes InputStreamEntity to send > null-length chunk > > I hope this will help to locate problem. >
Dmitry I'll try to get around to looking at the reproducer sometime later this week or early next week. Please bear with me. Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
