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

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

mercurial