File indexing completed on 2025-03-23 09:55:25
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2002 Waldo Bastian <bastian@kde.org> 0004 SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #ifndef _HTTPFILTER_H_ 0010 #define _HTTPFILTER_H_ 0011 0012 class KFilterBase; 0013 #include <QBuffer> 0014 0015 #include <QCryptographicHash> 0016 #include <QObject> 0017 0018 #include <QLoggingCategory> 0019 Q_DECLARE_LOGGING_CATEGORY(KIO_HTTP_FILTER) 0020 0021 class HTTPFilterBase : public QObject 0022 { 0023 Q_OBJECT 0024 public: 0025 HTTPFilterBase(); 0026 ~HTTPFilterBase() override; 0027 0028 void chain(HTTPFilterBase *previous); 0029 0030 public Q_SLOTS: 0031 virtual void slotInput(const QByteArray &d) = 0; 0032 0033 Q_SIGNALS: 0034 void output(const QByteArray &d); 0035 void error(const QString &); 0036 0037 protected: 0038 HTTPFilterBase *last; 0039 }; 0040 0041 class HTTPFilterChain : public HTTPFilterBase 0042 { 0043 Q_OBJECT 0044 public: 0045 HTTPFilterChain(); 0046 0047 void addFilter(HTTPFilterBase *filter); 0048 0049 public Q_SLOTS: 0050 void slotInput(const QByteArray &d) override; 0051 0052 private: 0053 HTTPFilterBase *first; 0054 }; 0055 0056 class HTTPFilterMD5 : public HTTPFilterBase 0057 { 0058 Q_OBJECT 0059 public: 0060 HTTPFilterMD5(); 0061 0062 QString md5(); 0063 0064 public Q_SLOTS: 0065 void slotInput(const QByteArray &d) override; 0066 0067 private: 0068 QCryptographicHash context; 0069 }; 0070 0071 class HTTPFilterGZip : public HTTPFilterBase 0072 { 0073 Q_OBJECT 0074 public: 0075 explicit HTTPFilterGZip(bool deflate = false /* for subclass HTTPFilterDeflate */); 0076 ~HTTPFilterGZip() override; 0077 0078 public Q_SLOTS: 0079 void slotInput(const QByteArray &d) override; 0080 0081 private: 0082 bool m_deflateMode; 0083 bool m_firstData; 0084 bool m_finished; 0085 KFilterBase *m_gzipFilter; 0086 }; 0087 0088 class HTTPFilterDeflate : public HTTPFilterGZip 0089 { 0090 Q_OBJECT 0091 public: 0092 HTTPFilterDeflate(); 0093 }; 0094 0095 #endif