atscppapi  1.0.9
C++ wrapper for Apache Traffic Server API
 All Classes Files Functions Enumerations Enumerator Macros
GzipDeflateTransformation.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 LinkedIn Corp. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of the license at
5  * http://www.apache.org/licenses/LICENSE-2.0
6  *
7  * Unless required by applicable law or agreed to in writing, software distributed under the
8  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9  * either express or implied.
10  *
11  */
12 
13 /**
14  * @file GzipDeflateTransformation.h
15  * @author Brian Geffon
16  * @author Manjesh Nilange
17  * @brief Gzip Deflate Transformation can be used to compress content.
18  */
19 
20 #pragma once
21 #ifndef ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_
22 #define ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_
23 
24 #include <string>
26 
27 namespace atscppapi {
28 
29 namespace transformations {
30 
31 /**
32  * Internal state for Deflate Transformations
33  * @private
34  */
35 class GzipDeflateTransformationState;
36 
37 /**
38  * @brief A TransformationPlugin to easily add gzip deflate to your TransformationPlugin chain.
39  *
40  * The GzipDeflateTransformation is a helper transformation that can be used
41  * to easily compress content. For a full example of GzipDeflateTransformation
42  * and GzipInflateTransformation see examples/gzip_transformation/.
43  *
44  * @note GzipDeflateTransformation DOES NOT set Content-Encoding headers, it is the
45  * users responsibility to set any applicable headers.
46  *
47  * @see GzipInflateTransformation
48  */
50 public:
51  /**
52  * A full example of how to use GzipDeflateTransformation and GzipInflateTransformation is available
53  * in examples/gzip_tranformation/
54  *
55  * @param transaction As with any TransformationPlugin you must pass in the transaction
56  * @param type because the GzipDeflateTransformation can be used with both requests and responses
57  * you must specify the Type.
58  *
59  * @see TransformationPlugin::Type
60  */
62 
63  /**
64  * Any TransformationPlugin must implement consume(), this method will take content
65  * from the transformation chain and gzip compress it.
66  *
67  * @param data the input data to compress
68  */
69  void consume(const std::string &data);
70 
71  /**
72  * Any TransformationPlugin must implement handleInputComplete(), this method will
73  * finalize the gzip compression and flush any remaining data and the epilouge.
74  */
75  void handleInputComplete();
76 
77  virtual ~GzipDeflateTransformation();
78 private:
79  GzipDeflateTransformationState *state_; /** Internal state for Gzip Deflate Transformations */
80 };
81 
82 }
83 
84 }
85 
86 
87 #endif /* ATSCPPAPI_GZIPDEFLATETRANSFORMATION_H_ */