A straight forward client handler pipeline consists of:
IcapRequestEncoder
The Encoder will take a IcapRequest
or IcapChunk
and transfer them
into a ASCII string that represents the ICAP protocol.
IcapResponseDecoder
The Decoder produces an ICAP protocol ASCII string as input and
creates IcapRequest
and IcapChunk
instances.
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast("encoder",new IcapRequestEncoder()); pipeline.addLast("decoder",new IcapResponseDecoder()); pipeline.addLast("handler",new IcapClientHandler()); return pipeline; }
You also have the possibility to abstract from the tedious message body chunk handling and add two additional handlers which will take care of the chunked message body. It is important to understand that in this scenario (if you plan to send a message body) you have to attach the message body to the respective HTTP request or response.
IcapChunkSeparator
This handler is useful when you create an IcapRequest
instance
containing HTTP request/response and a body encapsulated with one of the http messages.
The responsibility of this handler is then to extract the message body and send it as
chunks to the receiving side.
IcapChunkAggregator
This handler is useful when you don't want to handle individual
IcapChunk
instances but rather receive a combined IcapResponse
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast("encoder",new IcapRequestEncoder()); pipeline.addLast("chunkSeparator",new IcapChunkSeparator(4096)); pipeline.addLast("decoder",new IcapResponseDecoder()); pipeline.addLast("chunkAggregator",new IcapChunkAggregator(4096)); pipeline.addLast("handler",new IcapClientHandler()); return pipeline; }