00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 #ifndef __PION_SPDYDECOMPRESSOR_HEADER__
00011 #define __PION_SPDYDECOMPRESSOR_HEADER__
00012 
00013 
00014 #include <boost/noncopyable.hpp>
00015 #include <boost/shared_ptr.hpp>
00016 #include <pion/config.hpp>
00017 #include <pion/spdy/types.hpp>
00018 #include <zlib.h>
00019 
00020 
00021 namespace pion {    
00022 namespace spdy {    
00023 
00024 
00028 
00029 class PION_API decompressor
00030 {
00031 public:
00032 
00034     enum data_size_t {
00036         MAX_UNCOMPRESSED_DATA_BUF_SIZE = 16384
00037     };
00038     
00040     decompressor();
00041     
00043     ~decompressor();
00044     
00050     char* decompress(const char *compressed_data_ptr,
00051                      boost::uint32_t stream_id,
00052                      const spdy_control_frame_info& frame,
00053                      boost::uint32_t header_block_length);
00054 
00055     
00056 protected:
00057 
00063     bool spdy_decompress_header(const char *compressed_data_ptr,
00064                                 z_streamp decomp,
00065                                 boost::uint32_t length,
00066                                 boost::uint32_t& uncomp_length);
00067 
00068 
00069 private:
00070     
00072     z_streamp                           m_request_zstream;
00073 
00075     z_streamp                           m_response_zstream;
00076     
00078     boost::uint32_t                     m_dictionary_id;
00079     
00081     boost::uint8_t                      m_uncompressed_header[MAX_UNCOMPRESSED_DATA_BUF_SIZE];
00082 
00083     
00084     static const char                   SPDY_ZLIB_DICTIONARY[];
00085 };
00086     
00088 typedef boost::shared_ptr<decompressor>       decompressor_ptr;
00089     
00090 }   
00091 }   
00092 
00093 #endif
00094