2
* httppoll.h - HTTP polling proxy
3
* Copyright (C) 2003 Justin Karneges
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include "bytestream.h"
28
class HttpPoll : public ByteStream
32
enum Error { ErrConnectionRefused = ErrCustom, ErrHostNotFound, ErrProxyConnect, ErrProxyNeg, ErrProxyAuth };
33
HttpPoll(QObject *parent=0);
36
void setAuth(const QString &user, const QString &pass="");
37
void connectToUrl(const QString &url);
38
void connectToHost(const QString &proxyHost, int proxyPort, const QString &url);
40
int pollInterval() const;
41
void setPollInterval(int seconds);
64
void reset(bool clear=false);
65
QByteArray makePacket(const QString &ident, const QString &key, const QString &newkey, const QByteArray &block);
67
const QString & getKey(bool *);
70
class HttpProxyPost : public QObject
74
enum Error { ErrConnectionRefused, ErrHostNotFound, ErrSocket, ErrProxyConnect, ErrProxyNeg, ErrProxyAuth };
75
HttpProxyPost(QObject *parent=0);
78
void setAuth(const QString &user, const QString &pass="");
79
bool isActive() const;
80
void post(const QString &proxyHost, int proxyPort, const QString &url, const QByteArray &data, bool asProxy=true);
82
QByteArray body() const;
83
QString getHeader(const QString &) const;
90
void sock_connected();
91
void sock_connectionClosed();
92
void sock_readyRead();
99
void reset(bool clear=false);
102
class HttpProxyGetStream : public QObject
106
enum Error { ErrConnectionRefused, ErrHostNotFound, ErrSocket, ErrProxyConnect, ErrProxyNeg, ErrProxyAuth };
107
HttpProxyGetStream(QObject *parent=0);
108
~HttpProxyGetStream();
110
void setAuth(const QString &user, const QString &pass="");
111
bool isActive() const;
112
void get(const QString &proxyHost, int proxyPort, const QString &url, bool ssl=false, bool asProxy=false);
114
QString getHeader(const QString &) const;
115
int length() const; // -1 for unknown
119
void dataReady(const QByteArray &buf);
124
void sock_connected();
125
void sock_connectionClosed();
126
void sock_readyRead();
127
void sock_error(int);
129
void tls_readyRead();
130
void tls_readyReadOutgoing();
137
void reset(bool clear=false);
138
void processData(const QByteArray &block);