netwerk/streamconv/converters/nsHTTPCompressConv.h

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #if !defined (__nsHTTPCompressConv__h__)
     7 #define	__nsHTTPCompressConv__h__	1
     9 #include "nsIStreamConverter.h"
    10 #include "nsCOMPtr.h"
    12 #include "zlib.h"
    14 class nsIStringInputStream;
    16 #define NS_HTTPCOMPRESSCONVERTER_CID                \
    17 {                                                   \
    18     /* 66230b2b-17fa-4bd3-abf4-07986151022d */      \
    19     0x66230b2b,                                     \
    20     0x17fa,                                         \
    21     0x4bd3,                                         \
    22     {0xab, 0xf4, 0x07, 0x98, 0x61, 0x51, 0x02, 0x2d}\
    23 }
    26 #define	HTTP_DEFLATE_TYPE		"deflate"
    27 #define	HTTP_GZIP_TYPE	        "gzip"
    28 #define	HTTP_X_GZIP_TYPE	    "x-gzip"
    29 #define	HTTP_COMPRESS_TYPE	    "compress"
    30 #define	HTTP_X_COMPRESS_TYPE	"x-compress"
    31 #define	HTTP_IDENTITY_TYPE	    "identity"
    32 #define	HTTP_UNCOMPRESSED_TYPE	"uncompressed"
    34 typedef enum    {
    35         HTTP_COMPRESS_GZIP,
    36         HTTP_COMPRESS_DEFLATE,
    37         HTTP_COMPRESS_COMPRESS,
    38         HTTP_COMPRESS_IDENTITY
    39     }   CompressMode;
    41 class nsHTTPCompressConv	: public nsIStreamConverter	{
    42 public:
    43     // nsISupports methods
    44     NS_DECL_THREADSAFE_ISUPPORTS
    46 	NS_DECL_NSIREQUESTOBSERVER
    47     NS_DECL_NSISTREAMLISTENER
    49     // nsIStreamConverter methods
    50     NS_DECL_NSISTREAMCONVERTER
    53     nsHTTPCompressConv ();
    54     virtual ~nsHTTPCompressConv ();
    56 private:
    58     nsIStreamListener   *mListener; // this guy gets the converted data via his OnDataAvailable ()
    59 	CompressMode        mMode;
    61     unsigned char *mOutBuffer;
    62     unsigned char *mInpBuffer;
    64     uint32_t	mOutBufferLen;
    65     uint32_t	mInpBufferLen;
    67     nsCOMPtr<nsISupports>   mAsyncConvContext;
    68     nsCOMPtr<nsIStringInputStream>  mStream;
    70     nsresult do_OnDataAvailable (nsIRequest *request, nsISupports *aContext,
    71                                  uint64_t aSourceOffset, const char *buffer,
    72                                  uint32_t aCount);
    74     bool        mCheckHeaderDone;
    75     bool        mStreamEnded;
    76     bool        mStreamInitialized;
    77     bool        mDummyStreamInitialised;
    79     z_stream d_stream;
    80     unsigned mLen, hMode, mSkipCount, mFlags;
    82     uint32_t check_header (nsIInputStream *iStr, uint32_t streamLen, nsresult *rv);
    83 };
    86 #endif

mercurial