QHttp Class Reference |
Constant | Value | Description |
---|---|---|
QHttp::ConnectionModeHttp | 0 | The connection is a regular Http connection to the server |
QHttp::ConnectionModeHttps | 1 | The Https protocol is used and the connection is encrypted using SSL. |
When using the Https mode, care should be taken to connect to the sslErrors signal, and handle possible Ssl errors.
This enum was introduced in Qt 4.3.
See also QSslSocket.
This enum identifies the error that occurred.
Constant | Value | Description |
---|---|---|
QHttp::NoError | 0 | No error occurred. |
QHttp::HostNotFound | 2 | The host name lookup failed. |
QHttp::ConnectionRefused | 3 | The server refused the connection. |
QHttp::UnexpectedClose | 4 | The server closed the connection unexpectedly. |
QHttp::InvalidResponseHeader | 5 | The server sent an invalid response header. |
QHttp::WrongContentLength | 6 | The client could not read the content correctly because an error with respect to the content length occurred. |
QHttp::Aborted | 7 | The request was aborted with abort(). |
QHttp::ProxyAuthenticationRequiredError | 9 | QHttp is using a proxy, and the proxy server requires authentication to establish a connection. |
QHttp::AuthenticationRequiredError | 8 | The web server requires authentication to complete the request. |
QHttp::UnknownError | 1 | An error other than those specified above occurred. |
See also error().
This enum is used to specify the state the client is in:
Constant | Value | Description |
---|---|---|
QHttp::Unconnected | 0 | There is no connection to the host. |
QHttp::HostLookup | 1 | A host name lookup is in progress. |
QHttp::Connecting | 2 | An attempt to connect to the host is in progress. |
QHttp::Sending | 3 | The client is sending its request to the server. |
QHttp::Reading | 4 | The client's request has been sent and the client is reading the server's response. |
QHttp::Connected | 5 | The connection to the host is open, but the client is neither sending a request, nor waiting for a response. |
QHttp::Closing | 6 | The connection is closing down, but is not yet closed. (The state will be Unconnected when the connection is closed.) |
See also stateChanged() and state().
Constructs a QHttp object. The parent parameter is passed on to the QObject constructor.
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.
See also setHost().
Constructs a QHttp object. Subsequent requests are done by connecting to the server hostName on port port using the connection mode mode.
If port is 0, it will use the default port for the mode used (80 for Http and 443 for Https).
The parent parameter is passed on to the QObject constructor.
See also setHost().
Destroys the QHttp object. If there is an open connection, it is closed.
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).
See also clearPendingRequests().
This signal can be emitted when a web server on a given hostname and port requires authentication. The authenticator object can then be filled in with the required details to allow authentication and continue the connection.
Note: It is not possible to use a QueuedConnection to connect to this signal, as the connection will fail if the authenticator has not been filled in with new information when the signal returns.
This function was introduced in Qt 4.3.
See also QAuthenticator and QNetworkProxy.
Returns the number of bytes that can be read from the response content at the moment.
See also get(), post(), request(), readyRead(), read(), and readAll().
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().
See also hasPendingRequests() and abort().
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; instead, it 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.
See also stateChanged(), abort(), requestStarted(), requestFinished(), and done().
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.
See also currentSourceDevice(), get(), post(), and request().
Returns the identifier of the HTTP request being executed or 0 if there is no request being executed (i.e. they've all finished).
See also currentRequest().
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.
See also currentId().
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.
See also currentDestinationDevice(), post(), and request().
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).
Warning: done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.
See also dataSendProgress(), get(), post(), request(), and QProgressBar.
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).
Warning: done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.
See also dataReadProgress(), post(), request(), and QProgressBar.
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.
See also requestFinished(), error(), and errorString().
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.
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.
Sends a get request for path to the server set by setHost() or as specified in the constructor.
path must be a absolute path like /index.html or an absolute URI like http://www.trolltech.com/index.html and must be encoded with either QUrl::toPercentEncoding() or QUrl::encodedPath().
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; instead, it 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.
See also setHost(), post(), head(), request(), requestStarted(), requestFinished(), and done().
Returns true if there are any requests scheduled that have not yet been executed; otherwise returns false.
The request that is being executed is not considered as a scheduled request.
See also clearPendingRequests(), currentId(), and currentRequest().
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; instead, it 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.
See also setHost(), get(), post(), request(), requestStarted(), requestFinished(), and done().
Tells the QSslSocket used for the Http connection to ignore the errors reported in the sslErrors() signal.
Note that this function must be called from within a slot connected to the sslErrors() signal to have any effect.
See also QSslSocket and QSslSocket::sslErrors().
Returns the received response header of the most recently finished HTTP request. If no response has yet been received QHttpResponseHeader::isValid() will return false.
See also currentRequest().
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 and must be encoded with either QUrl::toPercentEncoding() or QUrl::encodedPath().
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; instead, it 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.
See also setHost(), get(), head(), request(), requestStarted(), requestFinished(), and done().
This is an overloaded member function, provided for convenience.
data is used as the content data of the HTTP request.
This signal can be emitted when a proxy that requires authentication is used. The authenticator object can then be filled in with the required details to allow authentication and continue the connection.
Note: It is not possible to use a QueuedConnection to connect to this signal, as the connection will fail if the authenticator has not been filled in with new information when the signal returns.
This function was introduced in Qt 4.3.
See also QAuthenticator and QNetworkProxy.
Reads maxlen bytes from the response content into data and returns the number of bytes read. Returns -1 if an error occurred.
See also get(), post(), request(), readyRead(), bytesAvailable(), and readAll().
Reads all the bytes from the response content and returns them.
See also get(), post(), request(), readyRead(), bytesAvailable(), and read().
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.
See also get(), post(), request(), readAll(), read(), and bytesAvailable().
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; instead, it 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.
See also setHost(), get(), post(), head(), requestStarted(), requestFinished(), and done().
This is an overloaded member function, provided for convenience.
data is used as the content data of the HTTP request.
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.
See also requestStarted(), done(), error(), and errorString().
This signal is emitted when processing the request identified by id starts.
See also requestFinished() and done().
This signal is emitted when the HTTP header of a server response is available. The header is passed in resp.
See also get(), post(), head(), request(), and readyRead().
Sets the HTTP server that is used for requests to hostName on port port.
The function does not block; instead, it 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.
See also get(), post(), head(), request(), requestStarted(), requestFinished(), and done().
This is an overloaded member function, provided for convenience.
Sets the HTTP server that is used for requests to hostName on port port using the connection mode mode.
If port is 0, it will use the default port for the mode used (80 for Http and 443 fopr Https).
The function does not block; instead, it 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.
See also get(), post(), head(), request(), requestStarted(), requestFinished(), and done().
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.
See also QFtp::setProxy().
This is an overloaded member function, provided for convenience.
Enables HTTP proxy support using the proxy settings from proxy. If proxy is a transparent proxy, QHttp will call QAbstractSocket::setProxy() on the underlying socket. If the type is QNetworkProxy::HttpCachingProxy, QHttp will behave like the previous function.
Note: for compatibility with Qt 4.3, if the proxy type is QNetworkProxy::HttpProxy and the request type is unencrypted (that is, ConnectionModeHttp), QHttp will treat the proxy as a caching proxy.
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; instead, it 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().
See also QObject::moveToThread() and Thread Support in Qt.
This function sets the user name userName and password password for web pages that require authentication.
The function does not block; instead, it 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.
Forwards the sslErrors signal from the QSslSocket used in QHttp. errors is the list of errors that occurred during the SSL handshake. Unless you call ignoreSslErrors() from within a slot connected to this signal when an error occurs, QHttp will tear down the connection immediately after emitting the signal.
This function was introduced in Qt 4.3.
See also QSslSocket and QSslSocket::ignoreSslErrors().
Returns the current state of the object. When the state changes, the stateChanged() signal is emitted.
See also State and stateChanged().
This signal is emitted when the state of the QHttp object changes. The argument state is the new state of the connection; it is one of the State values.
This usually happens when a request is started, but it can also happen when the server closes the connection or when a call to close() succeeded.
See also get(), post(), head(), request(), close(), state(), and State.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.4 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com