| def abort () |
| def attribute (code) |
| def downloadProgress (bytesReceived,bytesTotal) |
| def error (arg__1) |
| def errorCode () |
| def finished () |
| def hasRawHeader (headerName) |
| def header (header) |
| def ignoreSslErrors () |
| def ignoreSslErrors (errors) |
| def isFinished () |
| def isRunning () |
| def manager () |
| def metaDataChanged () |
| def operation () |
| def rawHeader (headerName) |
| def rawHeaderList () |
| def readBufferSize () |
| def request () |
| def setAttribute (code,value) |
| def setError (errorCode,errorString) |
| def setHeader (header,value) |
| def setOperation (operation) |
| def setRawHeader (headerName,value) |
| def setReadBufferSize (size) |
| def setRequest (request) |
| def setSslConfiguration (configuration) |
| def setUrl (url) |
| def sslConfiguration () |
| def sslErrors (errors) |
| def uploadProgress (bytesSent,bytesTotal) |
| def url () |
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager
The QNetworkReply class contains the data and meta data related to a request posted with QNetworkAccessManager . Like QNetworkRequest , it contains a URL and headers (both in parsed and raw form), some information about the reply’s state and the contents of the reply itself.
QNetworkReply is a sequential-access QIODevice , which means that once data is read from the object, it no longer kept by the device. It is therefore the application’s responsibility to keep this data if it needs to. Whenever more data is received from the network and processed, the QIODevice.readyRead() signal is emitted.
The QNetworkReply.downloadProgress() signal is also emitted when data is received, but the number of bytes contained in it may not represent the actual bytes received, if any transformation is done to the contents (for example, decompressing and removing the protocol overhead).
Even though QNetworkReply is a QIODevice connected to the contents of the reply, it also emits the QNetworkReply.uploadProgress() signal, which indicates the progress of the upload for operations that have such content.
Note
Do not delete the object in the slot connected to the QNetworkReply.error() or QNetworkReply.finished() signal. Use QObject.deleteLater() .
See also
| Parameter: | parent – QObject |
|---|
Creates a QNetworkReply object with parent parent .
You cannot directly instantiate QNetworkReply objects. Use QNetworkAccessManager functions to do that.
Indicates all possible error conditions found during the processing of the request.
| Constant | Description |
|---|---|
| QNetworkReply.NoError | no error condition. Note: When the HTTP protocol returns a redirect no error will be reported. You can check if there is a redirect with the QNetworkRequest.RedirectionTargetAttribute attribute. |
| QNetworkReply.ConnectionRefusedError | the remote server refused the connection (the server is not accepting requests) |
| QNetworkReply.RemoteHostClosedError | the remote server closed the connection prematurely, before the entire reply was received and processed |
| QNetworkReply.HostNotFoundError | the remote host name was not found (invalid hostname) |
| QNetworkReply.TimeoutError | the connection to the remote server timed out |
| QNetworkReply.OperationCanceledError | the operation was canceled via calls to QNetworkReply.abort() or QNetworkReply.close() before it was finished. |
| QNetworkReply.SslHandshakeFailedError | the SSL/TLS handshake failed and the encrypted channel could not be established. The QNetworkReply.sslErrors() signal should have been emitted. |
| QNetworkReply.ProxyConnectionRefusedError | the connection to the proxy server was refused (the proxy server is not accepting requests) |
| QNetworkReply.ProxyConnectionClosedError | the proxy server closed the connection prematurely, before the entire reply was received and processed |
| QNetworkReply.ProxyNotFoundError | the proxy host name was not found (invalid proxy hostname) |
| QNetworkReply.ProxyTimeoutError | the connection to the proxy timed out or the proxy did not reply in time to the request sent |
| QNetworkReply.ProxyAuthenticationRequiredError | the proxy requires authentication in order to honour the request but did not accept any credentials offered (if any) |
| QNetworkReply.ContentAccessDenied | the access to the remote content was denied (similar to HTTP error 401) |
| QNetworkReply.ContentOperationNotPermittedError | the operation requested on the remote content is not permitted |
| QNetworkReply.ContentNotFoundError | the remote content was not found at the server (similar to HTTP error 404) |
| QNetworkReply.AuthenticationRequiredError | the remote server requires authentication to serve the content but the credentials provided were not accepted (if any) |
| QNetworkReply.ContentReSendError | the request needed to be sent again, but this failed for example because the upload data could not be read a second time. |
| QNetworkReply.ProtocolUnknownError | the Network Access API cannot honor the request because the protocol is not known |
| QNetworkReply.ProtocolInvalidOperationError | the requested operation is invalid for this protocol |
| QNetworkReply.UnknownNetworkError | an unknown network-related error was detected |
| QNetworkReply.UnknownProxyError | an unknown proxy-related error was detected |
| QNetworkReply.UnknownContentError | an unknown error related to the remote content was detected |
| QNetworkReply.ProtocolFailure | a breakdown in protocol was detected (parsing error, invalid or unexpected responses, etc.) |
See also
Aborts the operation immediately and close down any network connections still open. Uploads still in progress are also aborted.
See also
QNetworkReply.close()
| Parameter: | code – Attribute |
|---|---|
| Return type: | QVariant |
| Parameters: |
|
|---|
| Parameter: | arg__1 – NetworkError |
|---|
| Return type: | NetworkError |
|---|
Returns the error that was found during the processing of this request. If no error was found, returns NoError .
See also
| Parameter: | headerName – QByteArray |
|---|---|
| Return type: | bool |
Returns true if the raw header of name headerName was sent by the remote server
See also
| Parameter: | header – KnownHeaders |
|---|---|
| Return type: | QVariant |
| Parameter: | errors – List of QSslError |
|---|
If this function is called, SSL errors related to network connection will be ignored, including certificate validation errors.
Note that calling this function without restraint may pose a security risk for your application. Use it with care.
This function can be called from the slot connected to the QNetworkReply.sslErrors() signal, which indicates which errors were found.
| Return type: | bool |
|---|
Returns true when the reply has finished or was aborted.
See also
| Return type: | bool |
|---|
Returns true when the request is still processing and the reply has not finished or was aborted yet.
See also
| Return type: | QNetworkAccessManager |
|---|
Returns the QNetworkAccessManager that was used to create this QNetworkReply object. Initially, it is also the parent object.
| Return type: | Operation |
|---|
Returns the operation that was posted for this reply.
See also
| Parameter: | headerName – QByteArray |
|---|---|
| Return type: | QByteArray |
Returns the raw contents of the header headerName as sent by the remote server. If there is no such header, returns an empty byte array, which may be indistinguishable from an empty header. Use QNetworkReply.hasRawHeader() to verify if the server sent such header field.
| Return type: | List of QByteArray |
|---|
Returns a list of headers fields that were sent by the remote server, in the order that they were sent. Duplicate headers are merged together and take place of the latter duplicate.
| Return type: | qint64 |
|---|
Returns the size of the read buffer, in bytes.
See also
| Return type: | QNetworkRequest |
|---|
Returns the request that was posted for this reply. In special, note that the URL for the request may be different than that of the reply.
| Parameters: |
|
|---|
| Parameters: |
|
|---|
Sets the error condition to be errorCode . The human-readable message is set with errorString .
Calling QNetworkReply.setError() does not emit the error( QNetworkReply.NetworkError ) signal.
See also
QNetworkReply.error() QIODevice.errorString()
| Parameters: |
|
|---|
| Parameter: | operation – Operation |
|---|
| Parameters: |
|
|---|
Sets the raw header headerName to be of value value . If headerName was previously set, it is overridden. Multiple HTTP headers of the same name are functionally equivalent to one single header with the values concatenated, separated by commas.
If headerName matches a known header, the value value will be parsed and the corresponding parsed form will also be set.
| Parameter: | size – qint64 |
|---|
Sets the size of the read buffer to be size bytes. The read buffer is the buffer that holds data that is being downloaded off the network, before it is read with QIODevice.read() . Setting the buffer size to 0 will make the buffer unlimited in size.
QNetworkReply will try to stop reading from the network once this buffer is full (i.e., QIODevice.bytesAvailable() returns size or more), thus causing the download to throttle down as well. If the buffer is not limited in size, QNetworkReply will try to download as fast as possible from the network.
Unlike QAbstractSocket.setReadBufferSize() , QNetworkReply cannot guarantee precision in the read buffer size. That is, QIODevice.bytesAvailable() can return more than size .
See also
| Parameter: | request – QNetworkRequest |
|---|
Sets the associated request for this object to be request . This value will be returned by QNetworkReply.request() .
Note: the request should be set when this object is created and not changed again.
| Parameter: | configuration – QSslConfiguration |
|---|
Sets the SSL configuration for the network connection associated with this request, if possible, to be that of config .
See also
| Parameter: | url – QUrl |
|---|
Sets the URL being processed to be url . Normally, the URL matches that of the request that was posted, but for a variety of reasons it can be different (for example, a file path being made absolute or canonical).
| Return type: | QSslConfiguration |
|---|
Returns the SSL configuration and state associated with this reply, if SSL was used. It will contain the remote server’s certificate, its certificate chain leading to the Certificate Authority as well as the encryption ciphers in use.
The peer’s certificate and its certificate chain will be known by the time QNetworkReply.sslErrors() is emitted, if it’s emitted.
See also
| Parameter: | errors – List of QSslError |
|---|
| Parameters: |
|
|---|
| Return type: | QUrl |
|---|
Returns the URL of the content downloaded or uploaded. Note that the URL may be different from that of the original request.