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 GzipInflateTransformation.h 00021 * @brief Gzip Inflate Transformation can be used to decompress gzipped content. 00022 */ 00023 00024 #pragma once 00025 #ifndef ATSCPPAPI_GZIPINFLATETRANSFORMATION_H_ 00026 #define ATSCPPAPI_GZIPINFLATETRANSFORMATION_H_ 00027 00028 #include <string> 00029 #include "atscppapi/TransformationPlugin.h" 00030 00031 namespace atscppapi { 00032 00033 namespace transformations { 00034 00035 /** 00036 * Internal state for Inflate Transformations 00037 * @private 00038 */ 00039 struct GzipInflateTransformationState; 00040 00041 /** 00042 * @brief A TransformationPlugin to easily add gzip inflate to your TransformationPlugin chain. 00043 * 00044 * The GzipInflateTransformation is a helper transformation that can be used 00045 * to easily decompress gzipped content. For a full example of GzipInflateTransformation 00046 * and GzipDeflateTransformation see examples/gzip_transformation/. 00047 * 00048 * @note GzipDeflateTransformation DOES NOT set or check Content-Encoding headers, it is the 00049 * users responsibility to set any applicable headers and check that the content is acctually 00050 * gzipped by checking the Content-Encoding header before creating a GzipInflateTransformation, 00051 * see examples/gzip_transformation/ for a full example. 00052 * 00053 * @see GzipDeflateTransformation 00054 */ 00055 class GzipInflateTransformation : public TransformationPlugin { 00056 public: 00057 /** 00058 * A full example of how to use GzipInflateTransformation and GzipDeflateTransformation is available 00059 * in examples/gzip_tranformation/ 00060 * 00061 * @param transaction As with any TransformationPlugin you must pass in the transaction 00062 * @param type because the GzipInflateTransformation can be used with both requests and responses 00063 * you must specify the Type. 00064 * 00065 * @see TransformationPlugin::Type 00066 */ 00067 GzipInflateTransformation(Transaction &transaction, TransformationPlugin::Type type); 00068 00069 /** 00070 * Any TransformationPlugin must implement consume(), this method will take content 00071 * from the transformation chain and gzip decompress it. 00072 * 00073 * @param data the input data to decompress 00074 */ 00075 void consume(const std::string &); 00076 00077 /** 00078 * Any TransformationPlugin must implement handleInputComplete(), this method will 00079 * finalize the gzip decompression. 00080 */ 00081 void handleInputComplete(); 00082 00083 virtual ~GzipInflateTransformation(); 00084 private: 00085 GzipInflateTransformationState *state_; /** Internal state for Gzip Deflate Transformations */ 00086 }; 00087 00088 } /* transformations */ 00089 00090 } /* atscppapi */ 00091 00092 #endif /* ATSCPPAPI_GZIPINFLATETRANSFORMATION_H_ */