A straight forward Server pipeline consists of:
IcapRequestDecoder
The Decoder produces an ICAP protocol ASCII string as input and
creates IcapRequest
and IcapChunk
instances.
IcapResponseEncoder
The Encoder will take a IcapResponse
or IcapChunk
and transfer them
into a ASCII string that represents the ICAP protocol.
@Override public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = pipeline(); pipeline.addLast("decoder",new IcapRequestDecoder()); pipeline.addLast("encoder",new IcapResponseEncoder()); pipeline.addLast("handler",new IcapServerHandler()); return pipeline; }
Analog to the Client example 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("decoder",new IcapRequestDecoder()); pipeline.addLast("chunkAggregator",new IcapChunkAggregator(4096)); pipeline.addLast("encoder",new IcapResponseEncoder()); pipeline.addLast("chunkSeparator",new IcapChunkSeparator(4096)); pipeline.addLast("handler",new IcapServerHandler()); return pipeline; }