Hi, I'm implementing a HTTP proxy. In my first layer I have a DemuxingProtocolCodedFactory, buffering data to my HeaderDecoder, which awaits the header separator. When this marker is encountered, HeaderDecoder reads the HTTP header, and writes it to the ProtocolDecoderOutput. I have a higher level IoHandler, which interprets the header and depending on the contents of the header decides to proxy the rest of the request or not.
My problem is that if the decision is to proxy the rest of the request, the remaining data held in the CumulativeDecoder is supposed to be streamed, not decoded. Therefore I need the rest of the data to go back to the lower layers somehow. The cleanest would be if CumulativeDecoder could just flush the remains of its cache back into the start of the chain again. If this is not possible to configure, I thought that I could implement a "FlushRestOfCacheDecoder", which does the same thing; awaits a call to encodable, checks if the rest of the request should be proxied or not and, if that is the case, proxies the data. This solution would be on the wrong level, but at least solve my problem. What stops me from doing this is that the higher level IoHandler is not invoked directly when the header is written to the ProtocolDecoderOutput. This is instead delayed until CumulativeDecoder has used all its data. Since my "FlushRestOfCacheDecoder" gets called before the header has been interpreted, and my logic requires that the header will be interpreted before further actions can be taken, it cannot make the decision to flush, and the demuxing codec factory finds no approporiate handler. How can I accomplish what I want to do (proxy rest of data after header) without going through all these hoops? I must be missing something. All I can think of now is to perform a direct call from HeaderDecoder to the higher level IoHandler, ignoring the ProtocolDecoderOutput. Thanks Alexander
