21 #ifndef BTHTTPCONNECTION_H
22 #define BTHTTPCONNECTION_H
27 #include <net/streamsocket.h>
28 #include <net/addressresolver.h>
96 bool get(
const QString & host,
const QString & path,
const QString & query,bt::Uint64 start,bt::Uint64 len);
117 void connectTimeout();
121 void startReplyTimer(
int timeout);
122 void stopReplyTimer();
123 void stopConnectTimer();
128 IDLE,RESOLVING,CONNECTING,ACTIVE,ERROR,CLOSED
138 bt::Uint64 data_received;
140 QByteArray piece_data;
141 bool response_header_received;
143 QString failure_reason;
146 bt::Uint64 content_length;
149 HttpGet(
const QString & host,
const QString & path,
const QString & query,bt::Uint64 start,bt::Uint64 len,
bool using_proxy);
153 bool finished()
const {
return data_received >= len;}
158 mutable QMutex mutex;
162 QTimer connect_timer;
164 Uint32 up_gid,down_gid;
165 bool close_when_finished;
void connectTo(const QUrl &url)
bool get(const QString &host, const QString &path, const QString &query, bt::Uint64 start, bt::Uint64 len)
void connectFinished(bool succeeded) override
void onDataReady(Uint8 *buf, Uint32 size) override
bool ok() const
Check if the connection is OK.
void setGroupIDs(Uint32 up, Uint32 down)
void connectToProxy(const QString &proxy, Uint16 proxy_port)
bool isRedirected() const
Is this connection redirected.
bool connected() const
See if we are connected.
bool closed() const
Has the connection been closed.
bool getData(QByteArray &data)
bool ready() const
Ready to do another request.
int getDownloadRate() const
Get the current download rate.
QUrl redirectedUrl() const
Get the redirected url.
const QString getStatusString() const
Get the status string.
int responseCode() const
Get the last http response code.