00001 /** 00002 Licensed to the Apache Software Foundation (ASF) under one 00003 or more contributor license agreements. See the NOTICE file 00004 distributed with this work for additional information 00005 regarding copyright ownership. The ASF licenses this file 00006 to you under the Apache License, Version 2.0 (the 00007 "License"); you may not use this file except in compliance 00008 with the License. You may obtain a copy of the License at 00009 00010 http://www.apache.org/licenses/LICENSE-2.0 00011 00012 Unless required by applicable law or agreed to in writing, software 00013 distributed under the License is distributed on an "AS IS" BASIS, 00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 See the License for the specific language governing permissions and 00016 limitations under the License. 00017 */ 00018 00019 /** 00020 * @file GzipDeflateTransformation.h 00021 * @brief Gzip Deflate Transformation can be used to compress content. 00022 */ 00023 00024 #pragma once 00025 #ifndef ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_ 00026 #define ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_ 00027 00028 #include <string> 00029 #include "atscppapi/TransformationPlugin.h" 00030 00031 namespace atscppapi { 00032 00033 namespace transformations { 00034 00035 /** 00036 * Internal state for Deflate Transformations 00037 * @private 00038 */ 00039 struct GzipDeflateTransformationState; 00040 00041 /** 00042 * @brief A TransformationPlugin to easily add gzip deflate to your TransformationPlugin chain. 00043 * 00044 * The GzipDeflateTransformation is a helper transformation that can be used 00045 * to easily compress content. For a full example of GzipDeflateTransformation 00046 * and GzipInflateTransformation see examples/gzip_transformation/. 00047 * 00048 * @note GzipDeflateTransformation DOES NOT set Content-Encoding headers, it is the 00049 * users responsibility to set any applicable headers. 00050 * 00051 * @see GzipInflateTransformation 00052 */ 00053 class GzipDeflateTransformation : public TransformationPlugin { 00054 public: 00055 /** 00056 * A full example of how to use GzipDeflateTransformation and GzipInflateTransformation is available 00057 * in examples/gzip_tranformation/ 00058 * 00059 * @param transaction As with any TransformationPlugin you must pass in the transaction 00060 * @param type because the GzipDeflateTransformation can be used with both requests and responses 00061 * you must specify the Type. 00062 * 00063 * @see TransformationPlugin::Type 00064 */ 00065 GzipDeflateTransformation(Transaction &transaction, TransformationPlugin::Type type); 00066 00067 /** 00068 * Any TransformationPlugin must implement consume(), this method will take content 00069 * from the transformation chain and gzip compress it. 00070 * 00071 * @param data the input data to compress 00072 */ 00073 void consume(const std::string &data); 00074 00075 /** 00076 * Any TransformationPlugin must implement handleInputComplete(), this method will 00077 * finalize the gzip compression and flush any remaining data and the epilouge. 00078 */ 00079 void handleInputComplete(); 00080 00081 virtual ~GzipDeflateTransformation(); 00082 private: 00083 GzipDeflateTransformationState *state_; /** Internal state for Gzip Deflate Transformations */ 00084 }; 00085 00086 } 00087 00088 } 00089 00090 00091 #endif /* ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_ */