Bug 460926 A11y hierachy is broken on Ubuntu 8.10 (GNOME 2.24), r=Evan.Yan sr=roc
[wine-gecko.git] / netwerk / streamconv / converters / nsHTTPCompressConv.h
blobf46f88d0bd01fbe2cdee01ef4e79b15b5ba17893
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * David Dick <ddick@cpan.org>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #if !defined (__nsHTTPCompressConv__h__)
40 #define __nsHTTPCompressConv__h__ 1
42 #include "nsIStreamConverter.h"
43 #include "nsIStringStream.h"
44 #include "nsCOMPtr.h"
46 #include "zlib.h"
48 #define NS_HTTPCOMPRESSCONVERTER_CID \
49 { \
50 /* 66230b2b-17fa-4bd3-abf4-07986151022d */ \
51 0x66230b2b, \
52 0x17fa, \
53 0x4bd3, \
54 {0xab, 0xf4, 0x07, 0x98, 0x61, 0x51, 0x02, 0x2d}\
58 #define HTTP_DEFLATE_TYPE "deflate"
59 #define HTTP_GZIP_TYPE "gzip"
60 #define HTTP_X_GZIP_TYPE "x-gzip"
61 #define HTTP_COMPRESS_TYPE "compress"
62 #define HTTP_X_COMPRESS_TYPE "x-compress"
63 #define HTTP_IDENTITY_TYPE "identity"
64 #define HTTP_UNCOMPRESSED_TYPE "uncompressed"
66 typedef enum {
67 HTTP_COMPRESS_GZIP,
68 HTTP_COMPRESS_DEFLATE,
69 HTTP_COMPRESS_COMPRESS,
70 HTTP_COMPRESS_IDENTITY
71 } CompressMode;
73 class nsHTTPCompressConv : public nsIStreamConverter {
74 public:
75 // nsISupports methods
76 NS_DECL_ISUPPORTS
78 NS_DECL_NSIREQUESTOBSERVER
79 NS_DECL_NSISTREAMLISTENER
81 // nsIStreamConverter methods
82 NS_DECL_NSISTREAMCONVERTER
85 nsHTTPCompressConv ();
86 virtual ~nsHTTPCompressConv ();
88 private:
90 nsIStreamListener *mListener; // this guy gets the converted data via his OnDataAvailable ()
91 CompressMode mMode;
93 unsigned char *mOutBuffer;
94 unsigned char *mInpBuffer;
96 PRUint32 mOutBufferLen;
97 PRUint32 mInpBufferLen;
99 nsCOMPtr<nsISupports> mAsyncConvContext;
100 nsCOMPtr<nsIStringInputStream> mStream;
102 nsresult do_OnDataAvailable (nsIRequest *request, nsISupports *aContext,
103 PRUint32 aSourceOffset, const char *buffer,
104 PRUint32 aCount);
106 PRBool mCheckHeaderDone;
107 PRBool mStreamEnded;
108 PRBool mStreamInitialized;
109 PRBool mDummyStreamInitialised;
111 z_stream d_stream;
112 unsigned mLen, hMode, mSkipCount, mFlags;
114 PRUint32 check_header (nsIInputStream *iStr, PRUint32 streamLen, nsresult *rv);
118 #endif