httpfilter.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _HTTPFILTER_H_
00021 #define _HTTPFILTER_H_
00022
00023 #include <config.h>
00024
00025 #ifdef HAVE_LIBZ
00026 #define DO_GZIP
00027 #endif
00028
00029 #ifdef DO_GZIP
00030 #include <zlib.h>
00031 #endif
00032
00033 #include <qobject.h>
00034 #include <kmdcodec.h>
00035
00036 class HTTPFilterBase : public QObject
00037 {
00038 Q_OBJECT
00039 public:
00040 HTTPFilterBase();
00041 ~HTTPFilterBase();
00042
00043 void chain(HTTPFilterBase *previous);
00044
00045 public slots:
00046 virtual void slotInput(const QByteArray &d) = 0;
00047
00048 signals:
00049 void output(const QByteArray &d);
00050 void error(int, const QString &);
00051
00052 protected:
00053 HTTPFilterBase *last;
00054 };
00055
00056 class HTTPFilterChain : public HTTPFilterBase
00057 {
00058 Q_OBJECT
00059 public:
00060 HTTPFilterChain();
00061
00062 void addFilter(HTTPFilterBase *filter);
00063
00064 public slots:
00065 void slotInput(const QByteArray &d);
00066
00067 private:
00068 HTTPFilterBase *first;
00069 };
00070
00071 class HTTPFilterMD5 : public HTTPFilterBase
00072 {
00073 Q_OBJECT
00074 public:
00075 HTTPFilterMD5();
00076
00077 QString md5();
00078
00079 public slots:
00080 void slotInput(const QByteArray &d);
00081
00082 private:
00083 KMD5 context;
00084 };
00085
00086
00087 class HTTPFilterGZip : public HTTPFilterBase
00088 {
00089 Q_OBJECT
00090 public:
00091 HTTPFilterGZip();
00092 ~HTTPFilterGZip();
00093
00094 public slots:
00095 void slotInput(const QByteArray &d);
00096
00097 protected:
00098 int get_byte();
00099 int checkHeader();
00100 #ifdef DO_GZIP
00101 z_stream zstr;
00102 bool bEof : 1;
00103 bool bHasHeader : 1;
00104 bool bHasFinished : 1;
00105 bool bPlainText : 1;
00106 bool bEatTrailer : 1;
00107 QByteArray headerData;
00108 int iTrailer;
00109 #endif
00110 };
00111
00112 class HTTPFilterDeflate : public HTTPFilterGZip
00113 {
00114 Q_OBJECT
00115 public:
00116 HTTPFilterDeflate();
00117 };
00118
00119 #endif
|