QNetworkReply

Synopsis

Functions

Virtual functions

Signals

Detailed Description

The PySide.QtNetwork.QNetworkReply class contains the data and headers for a request sent with PySide.QtNetwork.QNetworkAccessManager

The PySide.QtNetwork.QNetworkReply class contains the data and meta data related to a request posted with PySide.QtNetwork.QNetworkAccessManager . Like PySide.QtNetwork.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.

PySide.QtNetwork.QNetworkReply is a sequential-access PySide.QtCore.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 PySide.QtCore.QIODevice.readyRead() signal is emitted.

The PySide.QtNetwork.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 PySide.QtNetwork.QNetworkReply is a PySide.QtCore.QIODevice connected to the contents of the reply, it also emits the PySide.QtNetwork.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 PySide.QtNetwork.QNetworkReply.error() or PySide.QtNetwork.QNetworkReply.finished() signal. Use PySide.QtCore.QObject.deleteLater() .

class PySide.QtNetwork.QNetworkReply([parent=None])
Parameters:parentPySide.QtCore.QObject

Creates a PySide.QtNetwork.QNetworkReply object with parent parent .

You cannot directly instantiate PySide.QtNetwork.QNetworkReply objects. Use PySide.QtNetwork.QNetworkAccessManager functions to do that.

PySide.QtNetwork.QNetworkReply.NetworkError

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 PySide.QtNetwork.QNetworkReply.abort() or PySide.QtNetwork.QNetworkReply.close() before it was finished.
QNetworkReply.SslHandshakeFailedError the SSL/TLS handshake failed and the encrypted channel could not be established. The PySide.QtNetwork.QNetworkReply.sslErrors() signal should have been emitted.
QNetworkReply.TemporaryNetworkFailureError the connection was broken due to disconnection from the network, however the system has initiated roaming to another access point. The request should be resubmitted and will be processed as soon as the connection is re-established.
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.)
PySide.QtNetwork.QNetworkReply.abort()

Aborts the operation immediately and close down any network connections still open. Uploads still in progress are also aborted.

See also

PySide.QtNetwork.QNetworkReply.close()

PySide.QtNetwork.QNetworkReply.attribute(code)
Parameters:codePySide.QtNetwork.QNetworkRequest.Attribute
Return type:object
PySide.QtNetwork.QNetworkReply.downloadProgress(bytesReceived, bytesTotal)
Parameters:
  • bytesReceivedPySide.QtCore.qint64
  • bytesTotalPySide.QtCore.qint64
PySide.QtNetwork.QNetworkReply.error()
Return type:PySide.QtNetwork.QNetworkReply.NetworkError

Returns the error that was found during the processing of this request. If no error was found, returns NoError .

PySide.QtNetwork.QNetworkReply.error(arg__1)
Parameters:arg__1PySide.QtNetwork.QNetworkReply.NetworkError
PySide.QtNetwork.QNetworkReply.finished()
PySide.QtNetwork.QNetworkReply.hasRawHeader(headerName)
Parameters:headerNamePySide.QtCore.QByteArray
Return type:PySide.QtCore.bool

Returns true if the raw header of name headerName was sent by the remote server

PySide.QtNetwork.QNetworkReply.header(header)
Parameters:headerPySide.QtNetwork.QNetworkRequest.KnownHeaders
Return type:object
PySide.QtNetwork.QNetworkReply.ignoreSslErrors()

If this function is called, SSL errors related to network connection will be ignored, including certificate validation errors.

Warning

Be sure to always let the user inspect the errors reported by the PySide.QtNetwork.QNetworkReply.sslErrors() signal, and only call this method upon confirmation from the user that proceeding is ok. If there are unexpected errors, the reply should be aborted. Calling this method without inspecting the actual errors will most likely pose a security risk for your application. Use it with great care!

This function can be called from the slot connected to the PySide.QtNetwork.QNetworkReply.sslErrors() signal, which indicates which errors were found.

PySide.QtNetwork.QNetworkReply.ignoreSslErrors(errors)
Parameters:errors
PySide.QtNetwork.QNetworkReply.isFinished()
Return type:PySide.QtCore.bool

Returns true when the reply has finished or was aborted.

PySide.QtNetwork.QNetworkReply.isRunning()
Return type:PySide.QtCore.bool

Returns true when the request is still processing and the reply has not finished or was aborted yet.

PySide.QtNetwork.QNetworkReply.manager()
Return type:PySide.QtNetwork.QNetworkAccessManager

Returns the PySide.QtNetwork.QNetworkAccessManager that was used to create this PySide.QtNetwork.QNetworkReply object. Initially, it is also the parent object.

PySide.QtNetwork.QNetworkReply.metaDataChanged()
PySide.QtNetwork.QNetworkReply.operation()
Return type:PySide.QtNetwork.QNetworkAccessManager.Operation

Returns the operation that was posted for this reply.

PySide.QtNetwork.QNetworkReply.rawHeader(headerName)
Parameters:headerNamePySide.QtCore.QByteArray
Return type:PySide.QtCore.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 PySide.QtNetwork.QNetworkReply.hasRawHeader() to verify if the server sent such header field.

PySide.QtNetwork.QNetworkReply.rawHeaderList()
Return type:

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.

PySide.QtNetwork.QNetworkReply.rawHeaderPairs()
Return type:

Returns a list of raw header pairs.

PySide.QtNetwork.QNetworkReply.readBufferSize()
Return type:PySide.QtCore.qint64

Returns the size of the read buffer, in bytes.

PySide.QtNetwork.QNetworkReply.request()
Return type:PySide.QtNetwork.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.

PySide.QtNetwork.QNetworkReply.setAttribute(code, value)
Parameters:
PySide.QtNetwork.QNetworkReply.setError(errorCode, errorString)
Parameters:

Sets the error condition to be errorCode . The human-readable message is set with errorString .

Calling PySide.QtNetwork.QNetworkReply.setError() does not emit the error( QNetworkReply.NetworkError ) signal.

See also

PySide.QtNetwork.QNetworkReply.error() PySide.QtCore.QIODevice.errorString()

PySide.QtNetwork.QNetworkReply.setFinished(arg__1)
Parameters:arg__1PySide.QtCore.bool

Sets the reply as finished .

After having this set the replies data must not change.

PySide.QtNetwork.QNetworkReply.setHeader(header, value)
Parameters:
PySide.QtNetwork.QNetworkReply.setOperation(operation)
Parameters:operationPySide.QtNetwork.QNetworkAccessManager.Operation
PySide.QtNetwork.QNetworkReply.setRawHeader(headerName, value)
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.

PySide.QtNetwork.QNetworkReply.setReadBufferSize(size)
Parameters:sizePySide.QtCore.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.

PySide.QtNetwork.QNetworkReply will try to stop reading from the network once this buffer is full (i.e., PySide.QtCore.QIODevice.bytesAvailable() returns size or more), thus causing the download to throttle down as well. If the buffer is not limited in size, PySide.QtNetwork.QNetworkReply will try to download as fast as possible from the network.

Unlike QAbstractSocket.setReadBufferSize() , PySide.QtNetwork.QNetworkReply cannot guarantee precision in the read buffer size. That is, PySide.QtCore.QIODevice.bytesAvailable() can return more than size .

PySide.QtNetwork.QNetworkReply.setRequest(request)
Parameters:requestPySide.QtNetwork.QNetworkRequest

Sets the associated request for this object to be request . This value will be returned by PySide.QtNetwork.QNetworkReply.request() .

Note: the request should be set when this object is created and not changed again.

PySide.QtNetwork.QNetworkReply.setSslConfiguration(configuration)
Parameters:configurationPySide.QtNetwork.QSslConfiguration

Sets the SSL configuration for the network connection associated with this request, if possible, to be that of config .

PySide.QtNetwork.QNetworkReply.setUrl(url)
Parameters:urlPySide.QtCore.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).

PySide.QtNetwork.QNetworkReply.sslConfiguration()
Return type:PySide.QtNetwork.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 PySide.QtNetwork.QNetworkReply.sslErrors() is emitted, if it’s emitted.

PySide.QtNetwork.QNetworkReply.sslErrors(errors)
Parameters:errors
PySide.QtNetwork.QNetworkReply.uploadProgress(bytesSent, bytesTotal)
Parameters:
  • bytesSentPySide.QtCore.qint64
  • bytesTotalPySide.QtCore.qint64
PySide.QtNetwork.QNetworkReply.url()
Return type:PySide.QtCore.QUrl

Returns the URL of the content downloaded or uploaded. Note that the URL may be different from that of the original request.