PySide6.QtNetwork.QRestReply¶
- class QRestReply¶
- QRestReplyis a convenience wrapper for- QNetworkReply.- Details- QRestReplywraps a- QNetworkReplyand provides convenience methods for data and status handling. The methods provide convenience for typical RESTful client applications.- QRestReplydoesn’t take ownership of the wrapped- QNetworkReply, and the lifetime and ownership of the reply is as defined by- QNetworkAccessManagerdocumentation.- QRestReplyobject is not copyable, but is movable.- Added in version 6.7. - Synopsis¶- Methods¶- def - __init__()
- def - error()
- def - errorString()
- def - hasError()
- def - httpStatus()
- def - isSuccess()
- def - networkReply()
- def - readBody()
- def - readJson()
- def - readText()
- def - swap()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - __init__(reply)¶
- Parameters:
- reply – - QNetworkReply
 
 - Creates a - QRestReplyand initializes the wrapped- QNetworkReplyto- reply.- error()¶
- Return type:
 
 - Returns the last error, if any. The errors include errors such as network and protocol errors, but exclude cases when the server successfully responded with an HTTP status. - See also - errorString()¶
- Return type:
- str 
 
 - Returns a human-readable description of the last network error. - See also - hasError()¶
- Return type:
- bool 
 
 - Returns whether an error has occurred. This includes errors such as network and protocol errors, but excludes cases where the server successfully responded with an HTTP error status (for example - 500 Internal Server Error). Use- httpStatus()or- isHttpStatusSuccess()to get the HTTP status information.- See also - httpStatus()¶
- Return type:
- int 
 
 - Returns the HTTP status received in the server response. The value is 0 if not available (the status line has not been received, yet). - Note - The HTTP status is reported as indicated by the received HTTP response. An - error()may occur after receiving the status, for instance due to network disconnection while receiving a long response. These potential subsequent errors are not represented by the reported HTTP status.- See also - isHttpStatusSuccess()¶
- Return type:
- bool 
 
 - Returns whether the HTTP status is between 200..299. - See also - isSuccess()¶
- Return type:
- bool 
 
 - Returns whether the HTTP status is between 200..299 and no further errors have occurred while receiving the response (for example, abrupt disconnection while receiving the body data). This function is a convenient way to check whether the response is considered successful. - See also - networkReply()¶
- Return type:
 
 - Returns a pointer to the underlying - QNetworkReplywrapped by this object.- readBody()¶
- Return type:
 
 - Returns the received data as a QByteArray. - Calling this function consumes the data received so far, and any further calls to get response data will return empty until further data has been received. - See also - readJson()- readText()- readyRead()- readJson()¶
- Return type:
- object 
 
 - readText()¶
- Return type:
- str 
 
 - Returns the received data as a QString. - The received data is decoded into a QString (UTF-16). If available, the decoding uses the Content-Type header’s charset parameter to determine the source encoding. If the encoding information is not available or not supported by QStringConverter, UTF-8 is used by default. - Calling this function consumes the data received so far. Returns a default constructed value if no new data is available, or if the decoding is not supported by QStringConverter, or if the decoding has errors (for example invalid characters). - See also - readJson()- readBody()- readyRead()- swap(other)¶
- Parameters:
- other – - QRestReply