#include <qhttp.h>
Inheritance diagram for QHttp:


network
This class provides a direct interface to HTTP that allows you to have more control over the requests and that allows you to access the response header fields.
The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.
The operations that can be scheduled (they are called "requests" in the rest of the documentation) are the following: setHost(), get(), post(), head() and request().
All of these requests return a unique identifier that allows you to keep track of the request that is currently executed. When the execution of a request starts, the requestStarted() signal with the identifier is emitted and when the request is finished, the requestFinished() signal is emitted with the identifier and a bool that indicates if the request finished with an error.
To make an HTTP request you must set up suitable HTTP headers. The following example demonstrates, how to request the main HTML page from the Trolltech home page (i.e. the URL http://www.trolltech.com/index.html):
QHttpRequestHeader header("GET", "/index.html"); header.setValue("Host", "www.trolltech.com"); http->setHost("www.trolltech.com"); http->request(header);
For the common HTTP requests GET, POST and HEAD, QHttp provides the convenience functions get(), post() and head(). They already use a reasonable header and if you don't have to set special header fields, they are easier to use. The above example can also be written as:
http->setHost("www.trolltech.com"); // id == 1 http->get("/index.html"); // id == 2
For this example the following sequence of signals is emitted (with small variations, depending on network traffic, etc.):
requestStarted(1) requestFinished(1, false) requestStarted(2) stateChanged(Connecting) stateChanged(Sending) dataSendProgress(77, 77) stateChanged(Reading) responseHeaderReceived(responseheader) dataReadProgress(5388, 0) readyRead(responseheader) dataReadProgress(18300, 0) readyRead(responseheader) stateChanged(Connected) requestFinished(2, false) done(false) stateChanged(Closing) stateChanged(Unconnected)
The dataSendProgress() and dataReadProgress() signals in the above example are useful if you want to show a progressbar to inform the user about the progress of the download. The second argument is the total size of data. In certain cases it is not possible to know the total amount in advance, in which case the second argument is 0. (If you connect to a QProgressBar a total of 0 results in a busy indicator.)
When the response header is read, it is reported with the responseHeaderReceived() signal.
The readyRead() signal tells you that there is data ready to be read. The amount of data can then be queried with the bytesAvailable() function and it can be read with the read() or readAll() functions.
If an error occurs during the execution of one of the commands in a sequence of commands, all the pending commands (i.e. scheduled, but not yet executed commands) are cleared and no signals are emitted for them.
For example, if you have the following sequence of requests
http->setHost("www.foo.bar"); // id == 1 http->get("/index.html"); // id == 2 http->post("register.html", data); // id == 3
and the get() request fails because the host lookup fails, then the post() request is never executed and the signals would look like this:
requestStarted(1) requestFinished(1, false) requestStarted(2) stateChanged(HostLookup) requestFinished(2, true) done(true) stateChanged(Unconnected)
You can then get details about the error with the error() and errorString() functions. Note that only unexpected behavior, like network failure is considered as an error. If the server response contains an error status, like a 404 response, this is reported as a normal response case. So you should always check the status code of the response header.
The functions currentId() and currentRequest() provide more information about the currently executing request.
The functions hasPendingRequests() and clearPendingRequests() allow you to query and clear the list of pending requests.
Definition at line 148 of file qhttp.h.
Public Types | |
| enum | State |
| enum | Error |
Public Slots | |
| void | abort () |
Signals | |
| void | stateChanged (int) |
| void | responseHeaderReceived (const QHttpResponseHeader &resp) |
| void | readyRead (const QHttpResponseHeader &resp) |
| void | dataSendProgress (int, int) |
| void | dataReadProgress (int, int) |
| void | requestStarted (int) |
| void | requestFinished (int, bool) |
| void | done (bool) |
Public Member Functions | |
| QHttp (QObject *parent=0) | |
| QHttp (const QString &hostname, quint16 port=80, QObject *parent=0) | |
| virtual | ~QHttp () |
| int | setHost (const QString &hostname, quint16 port=80) |
| int | setSocket (QTcpSocket *socket) |
| int | setUser (const QString &username, const QString &password=QString()) |
| int | setProxy (const QString &host, int port, const QString &username=QString(), const QString &password=QString()) |
| int | get (const QString &path, QIODevice *to=0) |
| int | post (const QString &path, QIODevice *data, QIODevice *to=0) |
| int | post (const QString &path, const QByteArray &data, QIODevice *to=0) |
| int | head (const QString &path) |
| int | request (const QHttpRequestHeader &header, QIODevice *device=0, QIODevice *to=0) |
| int | request (const QHttpRequestHeader &header, const QByteArray &data, QIODevice *to=0) |
| int | closeConnection () |
| int | close () |
| qint64 | bytesAvailable () const |
| qint64 | read (char *data, qint64 maxlen) |
| QByteArray | readAll () |
| int | currentId () const |
| QIODevice * | currentSourceDevice () const |
| QIODevice * | currentDestinationDevice () const |
| QHttpRequestHeader | currentRequest () const |
| QHttpResponseHeader | lastResponse () const |
| bool | hasPendingRequests () const |
| void | clearPendingRequests () |
| State | state () const |
| Error | error () const |
| QString | errorString () const |
Private Member Functions | |
| Q_PRIVATE_SLOT (d_func(), void _q_startNextRequest()) Q_PRIVATE_SLOT(d_func() | |
| void | _q_slotReadyRead ()) Q_PRIVATE_SLOT(d_func() |
| void void | _q_slotConnected ()) Q_PRIVATE_SLOT(d_func() |
| void void void | _q_slotError (QAbstractSocket::SocketError)) Q_PRIVATE_SLOT(d_func() |
| void void void void | _q_slotClosed ()) Q_PRIVATE_SLOT(d_func() |
| void void void void void | _q_slotBytesWritten (qint64 numBytes)) Q_PRIVATE_SLOT(d_func() |
| void void void void void void | _q_slotDoFinished ()) Q_PRIVATE_SLOT(d_func() |
| void void void void void void void | _q_slotSendRequest ()) friend class QHttpNormalRequest |
Friends | |
| class | QHttpSetHostRequest |
| class | QHttpSetSocketRequest |
| class | QHttpSetUserRequest |
| class | QHttpSetProxyRequest |
| class | QHttpCloseRequest |
| class | QHttpPGHRequest |
| enum QHttp::State |
This enum is used to specify the state the client is in:
Unconnected There is no connection to the host. HostLookup A host name lookup is in progress. Connecting An attempt to connect to the host is in progress. Sending The client is sending its request to the server. Reading The client's request has been sent and the client is reading the server's response. Connected The connection to the host is open, but the client is neither sending a request, nor waiting for a response. Closing The connection is closing down, but is not yet closed. (The state will be Unconnected when the connection is closed.)
Definition at line 157 of file qhttp.h.
00157 { 00158 Unconnected, 00159 HostLookup, 00160 Connecting, 00161 Sending, 00162 Reading, 00163 Connected, 00164 Closing 00165 };
| enum QHttp::Error |
This enum identifies the error that occurred.
NoError No error occurred. HostNotFound The host name lookup failed. ConnectionRefused The server refused the connection. UnexpectedClose The server closed the connection unexpectedly. InvalidResponseHeader The server sent an invalid response header. WrongContentLength The client could not read the content correctly because an error with respect to the content length occurred. Aborted The request was aborted with abort(). UnknownError An error other than those specified above occurred.
Definition at line 166 of file qhttp.h.
00166 { 00167 NoError, 00168 UnknownError, 00169 HostNotFound, 00170 ConnectionRefused, 00171 UnexpectedClose, 00172 InvalidResponseHeader, 00173 WrongContentLength, 00174 Aborted 00175 };
| QHttp::QHttp | ( | QObject * | parent = 0 |
) | [explicit] |
Constructs a QHttp object. Subsequent requests are done by connecting to the server hostName on port port.
The parent parameter is passed on to the QObject constructor.
Definition at line 1526 of file qhttp.cpp.
References d.
01527 : QObject(*new QHttpPrivate, parent) 01528 { 01529 Q_D(QHttp); 01530 d->init(); 01531 01532 d->hostName = hostName; 01533 d->port = port; 01534 }
| QHttp::~QHttp | ( | ) | [virtual] |
Sets the HTTP server that is used for requests to hostName on port port.
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
Definition at line 1921 of file qhttp.cpp.
References d, and QHttpSetHostRequest.
Referenced by HttpWindow::downloadFile(), and TrackerClient::fetchPeerList().
01922 { 01923 Q_D(QHttp); 01924 return d->addRequest(new QHttpSetHostRequest(hostName, port)); 01925 }
| int QHttp::setSocket | ( | QTcpSocket * | socket | ) |
Replaces the internal QTcpSocket that QHttp uses with socket. This is useful if you want to use your own custom QTcpSocket subclass instead of the plain QTcpSocket that QHttp uses by default. QHttp does not take ownership of the socket, and will not delete socket when destroyed.
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
Note: If QHttp is used in a non-GUI thread that runs its own event loop, you must move socket to that thread before calling setSocket().
Definition at line 1948 of file qhttp.cpp.
References d, and QHttpSetSocketRequest.
01949 { 01950 Q_D(QHttp); 01951 return d->addRequest(new QHttpSetSocketRequest(socket)); 01952 }
This function sets the user name userName and password password for web pages that require authentication.
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
Definition at line 1967 of file qhttp.cpp.
References d, and QHttpSetUserRequest.
Referenced by HttpWindow::downloadFile(), and TrackerClient::fetchPeerList().
01968 { 01969 Q_D(QHttp); 01970 return d->addRequest(new QHttpSetUserRequest(userName, password)); 01971 }
| int QHttp::setProxy | ( | const QString & | host, | |
| int | port, | |||
| const QString & | username = QString(), |
|||
| const QString & | password = QString() | |||
| ) |
Enables HTTP proxy support, using the proxy server host on port port. username and password can be provided if the proxy server requires authentication.
Example:
void Ticker::getTicks() { http = new QHttp(this); connect(http, SIGNAL(done(bool)), this, SLOT(showPage())); http->setProxy("proxy.example.com", 3128); http->setHost("ticker.example.com"); http->get("/ticks.asp"); } void Ticker::showPage() { display(http->readAll()); }
QHttp supports non-transparent web proxy servers only, such as the Squid Web proxy cache server (from http://www.squid.org/). For transparent proxying, such as SOCKS5, use QNetworkProxy instead.
Definition at line 2002 of file qhttp.cpp.
References d, and QHttpSetProxyRequest.
02004 { 02005 Q_D(QHttp); 02006 return d->addRequest(new QHttpSetProxyRequest(host, port, username, password)); 02007 }
Sends a get request for path to the server set by setHost() or as specified in the constructor.
path must be an absolute path like /index.html or an absolute URI like http://www.trolltech.com/index.html.
If the IO device to is 0 the readyRead() signal is emitted every time new content data is available to read.
If the IO device to is not 0, the content data of the response is written directly to the device. Make sure that the to pointer is valid for the duration of the operation (it is safe to delete it when the requestFinished() signal is emitted).
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
Definition at line 2035 of file qhttp.cpp.
References d, header(), path, and QHttpPGHRequest.
Referenced by HttpWindow::downloadFile(), and TrackerClient::fetchPeerList().
02036 { 02037 Q_D(QHttp); 02038 QHttpRequestHeader header(QLatin1String("GET"), path); 02039 header.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive")); 02040 return d->addRequest(new QHttpPGHRequest(header, (QIODevice *) 0, to)); 02041 }
Here is the call graph for this function:

Sends a post request for path to the server set by setHost() or as specified in the constructor.
path must be an absolute path like /index.html or an absolute URI like http://www.trolltech.com/index.html.
The incoming data comes via the data IO device.
If the IO device to is 0 the readyRead() signal is emitted every time new content data is available to read.
If the IO device to is not 0, the content data of the response is written directly to the device. Make sure that the to pointer is valid for the duration of the operation (it is safe to delete it when the requestFinished() signal is emitted).
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
Definition at line 2071 of file qhttp.cpp.
References d, data, header(), path, and QHttpPGHRequest.
02072 { 02073 Q_D(QHttp); 02074 QHttpRequestHeader header(QLatin1String("POST"), path); 02075 header.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive")); 02076 return d->addRequest(new QHttpPGHRequest(header, data, to)); 02077 }
Here is the call graph for this function:

| int QHttp::post | ( | const QString & | path, | |
| const QByteArray & | data, | |||
| QIODevice * | to = 0 | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. data is used as the content data of the HTTP request.
Definition at line 2084 of file qhttp.cpp.
References d, data, header(), path, and QHttpPGHRequest.
02085 { 02086 Q_D(QHttp); 02087 QHttpRequestHeader header(QLatin1String("POST"), path); 02088 header.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive")); 02089 return d->addRequest(new QHttpPGHRequest(header, new QByteArray(data), to)); 02090 }
Here is the call graph for this function:

| int QHttp::head | ( | const QString & | path | ) |
Sends a header request for path to the server set by setHost() or as specified in the constructor.
path must be an absolute path like /index.html or an absolute URI like http://www.trolltech.com/index.html.
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
Definition at line 2110 of file qhttp.cpp.
References d, header(), path, and QHttpPGHRequest.
02111 { 02112 Q_D(QHttp); 02113 QHttpRequestHeader header(QLatin1String("HEAD"), path); 02114 header.setValue(QLatin1String("Connection"), QLatin1String("Keep-Alive")); 02115 return d->addRequest(new QHttpPGHRequest(header, (QIODevice*)0, 0)); 02116 }
Here is the call graph for this function:

| int QHttp::request | ( | const QHttpRequestHeader & | header, | |
| QIODevice * | data = 0, |
|||
| QIODevice * | to = 0 | |||
| ) |
Sends a request to the server set by setHost() or as specified in the constructor. Uses the header as the HTTP request header. You are responsible for setting up a header that is appropriate for your request.
The incoming data comes via the data IO device.
If the IO device to is 0 the readyRead() signal is emitted every time new content data is available to read.
If the IO device to is not 0, the content data of the response is written directly to the device. Make sure that the to pointer is valid for the duration of the operation (it is safe to delete it when the requestFinished() signal is emitted).
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
Definition at line 2145 of file qhttp.cpp.
References d, data, and header().
02146 { 02147 Q_D(QHttp); 02148 return d->addRequest(new QHttpNormalRequest(header, data, to)); 02149 }
Here is the call graph for this function:

| int QHttp::request | ( | const QHttpRequestHeader & | header, | |
| const QByteArray & | data, | |||
| QIODevice * | to = 0 | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. data is used as the content data of the HTTP request.
Definition at line 2156 of file qhttp.cpp.
References d, data, and header().
02157 { 02158 Q_D(QHttp); 02159 return d->addRequest(new QHttpNormalRequest(header, new QByteArray(data), to)); 02160 }
Here is the call graph for this function:

| int QHttp::closeConnection | ( | ) |
Behaves the same as close().
Definition at line 2197 of file qhttp.cpp.
References d, and QHttpCloseRequest.
02198 { 02199 Q_D(QHttp); 02200 return d->addRequest(new QHttpCloseRequest()); 02201 }
| int QHttp::close | ( | ) |
Closes the connection; this is useful if you have a keep-alive connection and want to close it.
For the requests issued with get(), post() and head(), QHttp sets the connection to be keep-alive. You can also do this using the header you pass to the request() function. QHttp only closes the connection to the HTTP server if the response header requires it to do so.
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted() and requestFinished().
When the request is started the requestStarted() signal is emitted. When it is finished the requestFinished() signal is emitted.
If you want to close the connection immediately, you have to use abort() instead.
Definition at line 2186 of file qhttp.cpp.
References d, and QHttpCloseRequest.
02187 { 02188 Q_D(QHttp); 02189 return d->addRequest(new QHttpCloseRequest()); 02190 }
| qint64 QHttp::bytesAvailable | ( | ) | const |
Returns the number of bytes that can be read from the response content at the moment.
Definition at line 1734 of file qhttp.cpp.
Referenced by readAll().
01735 { 01736 Q_D(const QHttp); 01737 #if defined(QHTTP_DEBUG) 01738 qDebug("QHttp::bytesAvailable(): %d bytes", (int)d->rba.size()); 01739 #endif 01740 return qint64(d->rba.size()); 01741 }
Here is the call graph for this function:

Reads maxlen bytes from the response content into data and returns the number of bytes read. Returns -1 if an error occurred.
Definition at line 1754 of file qhttp.cpp.
References d, qDebug(), and qWarning().
Referenced by readAll().
01755 { 01756 Q_D(QHttp); 01757 if (data == 0 && maxlen != 0) { 01758 qWarning("QHttp::read: Null pointer error"); 01759 return -1; 01760 } 01761 if (maxlen >= d->rba.size()) 01762 maxlen = d->rba.size(); 01763 int readSoFar = 0; 01764 while (!d->rba.isEmpty() && readSoFar < maxlen) { 01765 int nextBlockSize = d->rba.nextDataBlockSize(); 01766 int bytesToRead = qMin<qint64>(maxlen - readSoFar, nextBlockSize); 01767 memcpy(data + readSoFar, d->rba.readPointer(), bytesToRead); 01768 d->rba.free(bytesToRead); 01769 readSoFar += bytesToRead; 01770 } 01771 01772 d->bytesDone += maxlen; 01773 #if defined(QHTTP_DEBUG) 01774 qDebug("QHttp::read(): read %lld bytes (%lld bytes done)", maxlen, d->bytesDone); 01775 #endif 01776 return maxlen; 01777 }
Here is the call graph for this function:

| QByteArray QHttp::readAll | ( | ) |
Reads all the bytes from the response content and returns them.
Definition at line 1784 of file qhttp.cpp.
References bytesAvailable(), QByteArray::data(), int, read(), and QByteArray::resize().
Referenced by TrackerClient::httpRequestDone().
01785 { 01786 qint64 avail = bytesAvailable(); 01787 QByteArray tmp; 01788 tmp.resize(int(avail)); 01789 qint64 got = read(tmp.data(), int(avail)); 01790 tmp.resize(got); 01791 return tmp; 01792 }
Here is the call graph for this function:

| int QHttp::currentId | ( | ) | const |
Returns the identifier of the HTTP request being executed or 0 if there is no request being executed (i.e. they've all finished).
Definition at line 1800 of file qhttp.cpp.
References d.
01801 { 01802 Q_D(const QHttp); 01803 if (d->pending.isEmpty()) 01804 return 0; 01805 return d->pending.first()->id; 01806 }
| QIODevice * QHttp::currentSourceDevice | ( | ) | const |
Returns the QIODevice pointer that is used as the data source of the HTTP request being executed. If there is no current request or if the request does not use an IO device as the data source, this function returns 0.
This function can be used to delete the QIODevice in the slot connected to the requestFinished() signal.
Definition at line 1850 of file qhttp.cpp.
References d.
01851 { 01852 Q_D(const QHttp); 01853 if (d->pending.isEmpty()) 01854 return 0; 01855 return d->pending.first()->sourceDevice(); 01856 }
| QIODevice * QHttp::currentDestinationDevice | ( | ) | const |
Returns the QIODevice pointer that is used as to store the data of the HTTP request being executed. If there is no current request or if the request does not store the data to an IO device, this function returns 0.
This function can be used to delete the QIODevice in the slot connected to the requestFinished() signal.
Definition at line 1868 of file qhttp.cpp.
References d.
01869 { 01870 Q_D(const QHttp); 01871 if (d->pending.isEmpty()) 01872 return 0; 01873 return d->pending.first()->destinationDevice(); 01874 }
| QHttpRequestHeader QHttp::currentRequest | ( | ) | const |
Returns the request header of the HTTP request being executed. If the request is one issued by setHost() or close(), it returns an invalid request header, i.e. QHttpRequestHeader::isValid() returns false.
Definition at line 1816 of file qhttp.cpp.
References d.
01817 { 01818 Q_D(const QHttp); 01819 if (!d->pending.isEmpty()) { 01820 QHttpRequest *r = d->pending.first(); 01821 if (r->hasRequestHeader()) 01822 return r->requestHeader(); 01823 } 01824 return QHttpRequestHeader(); 01825 }
| QHttpResponseHeader QHttp::lastResponse | ( | ) | const |
Returns the received response header of the most recently finished HTTP request. If no response has yet been received QHttpResponseHeader::isValid() will return false.
Definition at line 1834 of file qhttp.cpp.
References d.
| bool QHttp::hasPendingRequests | ( | ) | const |
| void QHttp::clearPendingRequests | ( | ) |
Deletes all pending requests from the list of scheduled requests. This does not affect the request that is being executed. If you want to stop this this as well, use abort().
Definition at line 1898 of file qhttp.cpp.
References d.
Referenced by abort().
01899 { 01900 Q_D(QHttp); 01901 // delete all entires except the first one 01902 while (d->pending.count() > 1) 01903 delete d->pending.takeLast(); 01904 }
| QHttp::State QHttp::state | ( | ) | const |
Returns the current state of the object. When the state changes, the stateChanged() signal is emitted.
Definition at line 2642 of file qhttp.cpp.
References d.
Referenced by TrackerClient::timerEvent().
| QHttp::Error QHttp::error | ( | ) | const |
Returns the last error that occurred. This is useful to find out what happened when receiving a requestFinished() or a done() signal with the error argument true.
If you start a new request, the error status is reset to NoError.
Definition at line 2655 of file qhttp.cpp.
References d.
Referenced by TrackerClient::httpRequestDone().
| QString QHttp::errorString | ( | ) | const |
Returns a human-readable description of the last error that occurred. This is useful to present a error message to the user when receiving a requestFinished() or a done() signal with the error argument true.
Definition at line 2667 of file qhttp.cpp.
References d.
Referenced by HttpWindow::httpRequestFinished().
| void QHttp::abort | ( | ) | [slot] |
Aborts the current request and deletes all scheduled requests.
For the current request, the requestFinished() signal with the error argument true is emitted. For all other requests that are affected by the abort(), no signals are emitted.
Since this slot also deletes the scheduled requests, there are no requests left and the done() signal is emitted (with the error argument true).
Definition at line 1715 of file qhttp.cpp.
References Aborted, clearPendingRequests(), and d.
Referenced by HttpWindow::cancelDownload(), TrackerClient::httpRequestDone(), HttpWindow::readResponseHeader(), TrackerClient::stop(), and ~QHttp().
01716 { 01717 Q_D(QHttp); 01718 if (d->pending.isEmpty()) 01719 return; 01720 01721 d->finishedWithError(tr("Request aborted"), Aborted); 01722 clearPendingRequests(); 01723 if (d->socket) 01724 d->socket->abort(); 01725 d->closeConn(); 01726 }
| void QHttp::stateChanged | ( | int | state | ) | [signal] |
| void QHttp::responseHeaderReceived | ( | const QHttpResponseHeader & | resp | ) | [signal] |
This signal is emitted when the HTTP header of a server response is available. The header is passed in resp.
| void QHttp::readyRead | ( | const QHttpResponseHeader & | resp | ) | [signal] |
This signal is emitted when there is new response data to read.
If you specified a device in the request where the data should be written to, then this signal is not emitted; instead the data is written directly to the device.
The response header is passed in resp.
You can read the data with the readAll() or read() functions
This signal is useful if you want to process the data in chunks as soon as it becomes available. If you are only interested in the complete data, just connect to the requestFinished() signal and read the data then instead.
| void QHttp::dataSendProgress | ( | int | done, | |
| int | total | |||
| ) | [signal] |
This signal is emitted when this object sends data to a HTTP server to inform it about the progress of the upload.
done is the amount of data that has already arrived and total is the total amount of data. It is possible that the total amount of data that should be transferred cannot be determined, in which case total is 0.(If you connect to a QProgressBar, the progress bar shows a busy indicator if the total is 0).
| void QHttp::dataReadProgress | ( | int | done, | |
| int | total | |||
| ) | [signal] |
This signal is emitted when this object reads data from a HTTP server to indicate the current progress of the download.
done is the amount of data that has already arrived and total is the total amount of data. It is possible that the total amount of data that should be transferred cannot be determined, in which case total is 0.(If you connect to a QProgressBar, the progress bar shows a busy indicator if the total is 0).
| void QHttp::requestStarted | ( | int | id | ) | [signal] |
This signal is emitted when processing the request identified by id starts.
| void QHttp::requestFinished | ( | int | id, | |
| bool | error | |||
| ) | [signal] |
This signal is emitted when processing the request identified by id has finished. error is true if an error occurred during the processing; otherwise error is false.
| void QHttp::done | ( | bool | error | ) | [signal] |
This signal is emitted when the last pending request has finished; (it is emitted after the last request's requestFinished() signal). error is true if an error occurred during the processing; otherwise error is false.
| QHttp::Q_PRIVATE_SLOT | ( | d_func() | , | |
| void | _q_startNextRequest() | |||
| ) | [private] |
| void QHttp::_q_slotReadyRead | ( | ) | [private] |
| void void QHttp::_q_slotConnected | ( | ) | [private] |
| void void void QHttp::_q_slotError | ( | QAbstractSocket::SocketError | ) | [private] |
| void void void void QHttp::_q_slotClosed | ( | ) | [private] |
| void void void void void QHttp::_q_slotBytesWritten | ( | qint64 | numBytes | ) | [private] |
| void void void void void void QHttp::_q_slotDoFinished | ( | ) | [private] |
| void void void void void void void QHttp::_q_slotSendRequest | ( | ) | [private] |
Referenced by QHttpNormalRequest::start().
friend class QHttpSetHostRequest [friend] |
friend class QHttpSetSocketRequest [friend] |
friend class QHttpSetUserRequest [friend] |
friend class QHttpSetProxyRequest [friend] |
friend class QHttpCloseRequest [friend] |
friend class QHttpPGHRequest [friend] |
1.5.1