Preview

The ICAP protocol supports a special scenario whereby the client is enabled to send a pre-defined portion of the HTTP message body to the server and wait for further instructions. There server can the ask for more data by responding with 100 Continue which tells the client to send the rest of the message body, or with 204 No Content (If the client allows this!) and the client knows ok no modification was made on the request. The Server is also capable of sending a normal 200 OK message back to the client. This circumstance complicates the protocol handling for a server or client. We have therefore made a simple example that can be found under ch.mimo.netty.example.icap.preview.* which will help to understand the inner workings of such a preview request for client and server.

In order to detect whether a IcapRequest or IcapChunk belongs to a preview message we have added getters on each object that indicate if a request or chunk participates on a preview interaction.

/**
  	* @return whether this message is a preview of the actual message.
  	*/
  	boolean isPreviewMessage();
/**
	 * @return boolean true if this chunk is preview.
	 */
	boolean isPreviewChunk();

The best way to handler preview requests is configuring a IcapChunkAggregator into your pipeline. This will guarantee that once you have sent the 100 Continue response you will get the same IcapRequest instance containing the rest of the body that was not sent in the preview mode.