Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
inflating_fetch.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef NET_INSTAWEB_HTTP_PUBLIC_INFLATING_FETCH_H_
20 #define NET_INSTAWEB_HTTP_PUBLIC_INFLATING_FETCH_H_
21 
29 
30 namespace net_instaweb {
31 
32 class MessageHandler;
33 
45  public:
46  explicit InflatingFetch(AsyncFetch* fetch);
47  virtual ~InflatingFetch();
48 
52  void EnableGzipFromBackend();
53 
60  static bool UnGzipValueIfCompressed(const HTTPValue& src,
61  ResponseHeaders* headers,
62  HTTPValue* dest,
63  MessageHandler* handler);
67  static bool GzipValue(int compression_level, const HTTPValue& http_value,
68  HTTPValue* compressed_value, ResponseHeaders* headers,
69  MessageHandler* handler);
70 
71  protected:
74  virtual bool HandleWrite(const StringPiece& sp, MessageHandler* handler);
75 
78  virtual void HandleHeadersComplete();
79  virtual void HandleDone(bool success);
80  virtual void Reset();
81 
82  private:
83  void InitInflater(GzipInflater::InflateType, const StringPiece& value);
84 
87  bool IsCompressionAllowedInRequest();
88 
89  scoped_ptr<GzipInflater> inflater_;
90 
92  bool request_checked_for_accept_encoding_;
93 
95  bool compression_desired_;
96 
99  bool inflate_failure_;
100 
101 
102 };
103 
104 }
105 
106 #endif
static bool UnGzipValueIfCompressed(const HTTPValue &src, ResponseHeaders *headers, HTTPValue *dest, MessageHandler *handler)
Definition: http_value.h:38
virtual bool HandleWrite(const StringPiece &sp, MessageHandler *handler)
Read/write API for HTTP response headers.
Definition: response_headers.h:37
Definition: scoped_ptr.h:30
virtual void HandleHeadersComplete()
Definition: async_fetch.h:278
Definition: async_fetch.h:53
static bool GzipValue(int compression_level, const HTTPValue &http_value, HTTPValue *compressed_value, ResponseHeaders *headers, MessageHandler *handler)
Definition: message_handler.h:39
Definition: inflating_fetch.h:44