About append-transform.c This example is based on null-transform.c. It appends text to the body of an HTML text response document on its way from the cache to the client. The plugin first makes sure that it has received a "200 OK" response from the origin server. It then verifies that the returned document is of type "text/html". It "transforms" the document by appending text to the file. To read and write to the body of the document, the plugin uses functions similar to those in null-transform.c. You place the text to be appended in a file, and you must provide the path to the file in plugin.config. In other words, plugin.config must have a line similar to the following: On NT: AppendTransform.dll path/to/file On Solaris: append-transform.so path/to/file Specify an absolute path to the text file, or a relative path as described in the file-plugin README. INKPluginInit does the following: - makes sure that there is a text file specified in plugin.config (if not, it returns an error message) - calls the function load to load the contents of the file into a buffer to be appended to HTML response bodies - sets up the global hook to call back the plugin: INKHttpHookAdd(INK_HTTP_READ_RESPONSE_HDR_HOOK, INKContCreate (transform_plugin, NULL)); The load function does the following (similar to file-1.c): - opens the file specified in plugin.config using INKfopen - creates a buffer for the text to be appended using INKIOBufferCreate - creates a buffer reader for the text to be appended using INKIOBufferReaderAlloc - reads the contents of the file in to the buffer using: INKIOBufferStart INKIOBufferBlockWriteStart INKfread INKIOBufferProduce INKIOBufferReaderAvail - closes the file using INKfclose The transform_plugin function does the following: - tests the response body to make sure it is text/html, using the function "transformable". The transformable function uses the following API calls: INKHttpTxnServerRespGet INKHttpHdrStatusGet INKMimeHdrFieldFind INKMimeFieldValueGet - if the response body is deemed transformable, transform_plugin calls transform_add - continues the HTTP transaction using INKHttpTxnReenable The transform_add function does the following: - creates a continuation for the append transform, using INKTransformCreate (append_transform, txnp); The handler function for this continuation is append_transform. - adds a transaction hook for the append transform, using INKHttpTxnHookAdd(txnp, INK_HTTP_RESPONSE_TRANSFORM_HOOK, connp); This transaction hook sets up a callback during transactions. When the event INK_HTTP_RESPONSE_TRANSFORM_HOOK happens, the append_transform function is called back. The remaining functions in the plugin, append_transform and handle_transform, are similar to null_transform and handle_transform in the null-transform.c plugin.