On Wed, 2007-02-07 at 17:30 +0100, Stojce Dimski wrote: > Hi Oleg, > > So to summarize when I receive a request > a) without content - triggers just 'requestReceived' > b) with content - is also followed with several 'inputReady' until > decoder.isCompleted() returns true >
Yes, Sir > 1) In your 'ThrottlingHttpServiceHandler.inputReady you just > consumeContent, where do you invoke the processing of the request once > received ? Take a look at the AsyncHttpServer sample. It makes use of HttpRequestHandler instances to process individual requests. > When receiving request with content do I have to override > this method adding the check decoder.isCompleted() and invoking > 'processRequest' ? > I would recommend you to start with a simple custom NHttpServiceHandler implementation, get something working and then work on improving it with a more sophisticated memory management and what not. > 2) When I receive a 'requestReceived' is it received with request line + > headers, but without content in case of requests with content ? Yes, Sir > I am > asking this because here I can prepare a new request to invoke to a > destination host, this request will have slightly modified in line of > proxy servers compliance. > Yes, Sir > I think that I have to do some 'content transformation' as I have to > make a destination request with slightly modified headers and eventually > to normalize the response (deflate, dechunk)... Chunk encoding / decoding will be taken care for you. You can tweak some headers as you see fit without actually having to modify the request body. Try to stay away from messing around with the content unless you really have to. This will help you avoid the complexity of having to deal with worker threads and synchronization between them and the I/O threads. > > 3) What scope have suspendInput() calls ? > The I/O selector will no longer select input events for the given channel / connection. No input of what so ever. > The flow of the calls is something like this: > a) receive a request > b) make a new slightly modified request > c) invoke request to destination host (trough a nio client) > d) receive a response > e) translate received response (transforming it) to a response of a) > > Excuse my ignorance but I continue to not see a way to 'wait' for c) and > d) before doing e)... This is the bane of the NIO programming. You have to get used to thinking in terms of events, event handlers and contexts. You no longer can think in terms of sequential event flows. > Am I thinking and working like salmons and going upstream here ? > Probably I am not getting this 'suspend' stuff, but is there some sample > code ? > Forget I/O throttling for the time being. Just buffer content in memory for a start. You may want to take a look at the ServerHandler in Synapse written by Asankha. The service makes use of java.nio.channels.Pipe to stream content from server workers to client workers. I will put together a sample of a trivial proxy at some point of time, but I would like to get SSL support implemented first Cheers Oleg > Thanks to very nice and helpful comrade, > Stojce > > > --------------------------------------------------------------------- > 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]
