#include <qgshttptransaction.h>
This class extends the Qt QHttp concept by being able to recognise and respond to redirection responses (e.g. HTTP code 302)
Definition at line 36 of file qgshttptransaction.h.
Public Slots | |
| void | dataStarted (int id) |
| void | dataHeaderReceived (const QHttpResponseHeader &resp) |
| void | dataReceived (const QHttpResponseHeader &resp) |
| void | dataProgress (int done, int total) |
| void | dataFinished (int id, bool error) |
| void | transactionFinished (bool error) |
| void | dataStateChanged (int state) |
| void | networkTimedOut () |
Signals | |
| void | setProgress (int theProgress, int theTotalSteps) |
| emit a signal to notify of a progress event | |
| void | statusChanged (QString theStatusQString) |
| emit a signal to be caught by qgisapp and display a msg on status bar | |
Public Member Functions | |
| QgsHttpTransaction (QString uri, QString proxyHost=QString(), int proxyPort=80, QString proxyUser=QString(), QString proxyPass=QString()) | |
| Constructor. | |
| virtual | ~QgsHttpTransaction () |
| Destructor. | |
| void | getAsynchronously () |
| bool | getSynchronously (QByteArray &respondedContent, int redirections=0, const QByteArray *postData=0) |
| Gets the response synchronously. | |
| QString | responseContentType () |
| QString | errorString () |
| If an operation returns 0 (e.g. | |
Private Attributes | |
| QHttp * | http |
| Indicates the associated QHttp object. | |
| int | httpid |
| Indicates the QHttp ID. | |
| bool | httpactive |
| Indicates if the transaction is in progress. | |
| QByteArray | httpresponse |
| QString | httpresponsecontenttype |
| QString | httpurl |
| The original URL requested for this transaction. | |
| QString | httphost |
| The host being used for this transaction. | |
| int | httpport |
| The port being used for this transaction. | |
| QString | httpuser |
| The username being used for this transaction. | |
| QString | httppass |
| The password being used for this transaction. | |
| QString | httpredirecturl |
| If not empty, indicates that the QHttp is a redirect to the contents of this variable. | |
| int | httpredirections |
| Number of http redirections this transaction has been subjected to. | |
| QTimer * | mWatchdogTimer |
| Indicates the associated QTimer object - used to detect network timeouts. | |
| QString | mError |
| The error message associated with the last HTTP error. | |
| QgsHttpTransaction::QgsHttpTransaction | ( | QString | uri, | |
| QString | proxyHost = QString(), |
|||
| int | proxyPort = 80, |
|||
| QString | proxyUser = QString(), |
|||
| QString | proxyPass = QString() | |||
| ) |
| QgsHttpTransaction::~QgsHttpTransaction | ( | ) | [virtual] |
| void QgsHttpTransaction::getAsynchronously | ( | ) |
Definition at line 64 of file qgshttptransaction.cpp.
| bool QgsHttpTransaction::getSynchronously | ( | QByteArray & | respondedContent, | |
| int | redirections = 0, |
|||
| const QByteArray * | postData = 0 | |||
| ) |
Gets the response synchronously.
The function returns FALSE if there is an error while getting the response.
| [out] | respondedContent | is replaced with the new content. |
| [in] | redirections | is used to measure how many http redirections we've been through. Clients typically don't need to set this. |
| postData | data to send with the http message. This is only used for HTTP POST. If 0 then the request is done with HTTP GET. |
Definition at line 71 of file qgshttptransaction.cpp.
References dataFinished(), dataHeaderReceived(), dataProgress(), dataReceived(), dataStarted(), dataStateChanged(), getSynchronously(), http, HTTP_PORT_DEFAULT, httpactive, httphost, httpid, httppass, httpport, httpredirections, httpredirecturl, httpresponse, httpurl, httpuser, mError, mWatchdogTimer, NETWORK_TIMEOUT_MSEC, networkTimedOut(), QgsDebugMsg, statusChanged(), and transactionFinished().
Referenced by getSynchronously().
| QString QgsHttpTransaction::responseContentType | ( | ) |
| QString QgsHttpTransaction::errorString | ( | ) |
If an operation returns 0 (e.g.
getSynchronously()), this function returns the text of the error associated with the failure. Interactive users of this provider can then, for example, call a QMessageBox to display the contents.
Definition at line 468 of file qgshttptransaction.cpp.
References mError.
| void QgsHttpTransaction::dataStarted | ( | int | id | ) | [slot] |
Definition at line 224 of file qgshttptransaction.cpp.
References QgsDebugMsg.
Referenced by getSynchronously().
| void QgsHttpTransaction::dataHeaderReceived | ( | const QHttpResponseHeader & | resp | ) | [slot] |
Definition at line 230 of file qgshttptransaction.cpp.
References httpredirecturl, httpresponsecontenttype, mError, mWatchdogTimer, NETWORK_TIMEOUT_MSEC, and QgsDebugMsg.
Referenced by getSynchronously().
| void QgsHttpTransaction::dataReceived | ( | const QHttpResponseHeader & | resp | ) | [slot] |
Definition at line 261 of file qgshttptransaction.cpp.
References http, and httpresponse.
Referenced by getSynchronously().
| void QgsHttpTransaction::dataProgress | ( | int | done, | |
| int | total | |||
| ) | [slot] |
Definition at line 279 of file qgshttptransaction.cpp.
References mWatchdogTimer, NETWORK_TIMEOUT_MSEC, and statusChanged().
Referenced by getSynchronously().
| void QgsHttpTransaction::dataFinished | ( | int | id, | |
| bool | error | |||
| ) | [slot] |
Definition at line 304 of file qgshttptransaction.cpp.
References http, httpactive, httpresponse, mError, and QgsDebugMsg.
Referenced by getSynchronously().
| void QgsHttpTransaction::transactionFinished | ( | bool | error | ) | [slot] |
Definition at line 352 of file qgshttptransaction.cpp.
References http, httpactive, httpresponse, mError, and QgsDebugMsg.
Referenced by getSynchronously().
| void QgsHttpTransaction::dataStateChanged | ( | int | state | ) | [slot] |
Definition at line 397 of file qgshttptransaction.cpp.
References httphost, httpurl, mWatchdogTimer, NETWORK_TIMEOUT_MSEC, QgsDebugMsg, and statusChanged().
Referenced by getSynchronously().
| void QgsHttpTransaction::networkTimedOut | ( | ) | [slot] |
Definition at line 454 of file qgshttptransaction.cpp.
References httpactive, mError, NETWORK_TIMEOUT_MSEC, and QgsDebugMsg.
Referenced by getSynchronously().
| void QgsHttpTransaction::setProgress | ( | int | theProgress, | |
| int | theTotalSteps | |||
| ) | [signal] |
emit a signal to notify of a progress event
| void QgsHttpTransaction::statusChanged | ( | QString | theStatusQString | ) | [signal] |
emit a signal to be caught by qgisapp and display a msg on status bar
Referenced by dataProgress(), dataStateChanged(), and getSynchronously().
QHttp* QgsHttpTransaction::http [private] |
Indicates the associated QHttp object.
Definition at line 120 of file qgshttptransaction.h.
Referenced by dataFinished(), dataReceived(), getSynchronously(), and transactionFinished().
int QgsHttpTransaction::httpid [private] |
Indicates the QHttp ID.
Definition at line 125 of file qgshttptransaction.h.
Referenced by getSynchronously().
bool QgsHttpTransaction::httpactive [private] |
Indicates if the transaction is in progress.
Definition at line 130 of file qgshttptransaction.h.
Referenced by dataFinished(), getSynchronously(), networkTimedOut(), and transactionFinished().
QByteArray QgsHttpTransaction::httpresponse [private] |
Definition at line 135 of file qgshttptransaction.h.
Referenced by dataFinished(), dataReceived(), getSynchronously(), and transactionFinished().
QString QgsHttpTransaction::httpresponsecontenttype [private] |
Definition at line 140 of file qgshttptransaction.h.
Referenced by dataHeaderReceived(), and responseContentType().
QString QgsHttpTransaction::httpurl [private] |
The original URL requested for this transaction.
Definition at line 145 of file qgshttptransaction.h.
Referenced by dataStateChanged(), and getSynchronously().
QString QgsHttpTransaction::httphost [private] |
The host being used for this transaction.
Definition at line 150 of file qgshttptransaction.h.
Referenced by dataStateChanged(), and getSynchronously().
int QgsHttpTransaction::httpport [private] |
The port being used for this transaction.
Definition at line 155 of file qgshttptransaction.h.
Referenced by getSynchronously().
QString QgsHttpTransaction::httpuser [private] |
The username being used for this transaction.
Definition at line 160 of file qgshttptransaction.h.
Referenced by getSynchronously().
QString QgsHttpTransaction::httppass [private] |
The password being used for this transaction.
Definition at line 165 of file qgshttptransaction.h.
Referenced by getSynchronously().
QString QgsHttpTransaction::httpredirecturl [private] |
If not empty, indicates that the QHttp is a redirect to the contents of this variable.
Definition at line 171 of file qgshttptransaction.h.
Referenced by dataHeaderReceived(), and getSynchronously().
int QgsHttpTransaction::httpredirections [private] |
Number of http redirections this transaction has been subjected to.
TODO: Use this as part of a redirection loop detector
Definition at line 180 of file qgshttptransaction.h.
Referenced by getSynchronously().
QTimer* QgsHttpTransaction::mWatchdogTimer [private] |
Indicates the associated QTimer object - used to detect network timeouts.
Definition at line 185 of file qgshttptransaction.h.
Referenced by dataHeaderReceived(), dataProgress(), dataStateChanged(), and getSynchronously().
QString QgsHttpTransaction::mError [private] |
The error message associated with the last HTTP error.
Definition at line 190 of file qgshttptransaction.h.
Referenced by dataFinished(), dataHeaderReceived(), errorString(), getSynchronously(), networkTimedOut(), and transactionFinished().
1.5.1