Skip to content

NetworkReply

⋔ Inheritance diagram

graph TD
  1473573998784["network.NetworkReply"]
  140713234304496["builtins.object"]
  140713234304496 --> 1473573998784

🛈 DocStrings

Contains the data and headers for a request sent with QNetworkAccessManager.

Source code in prettyqt\network\networkreply.py
class NetworkReply:
    """Contains the data and headers for a request sent with QNetworkAccessManager."""

    def __init__(self, reply: QtNetwork.QNetworkReply):
        self.item = reply

    def __getattr__(self, val):
        return getattr(self.item, val)

    def get_error(self) -> NetworkErrorStr:
        """Return error type.

        Returns:
            error type
        """
        return NETWORK_ERROR.inverse[self.error()]

    def set_raw_headers(self, headers: dict[str, str]):
        for k, v in headers.items():
            self.setRawHeader(
                QtCore.QByteArray(k.encode()), QtCore.QByteArray(v.encode())
            )

    def get_raw_headers(self) -> dict[str, str]:
        return {
            h.data().decode(): self.rawHeader(h).data().decode()
            for h in self.rawHeaderList()
        }

get_error() -> NetworkErrorStr

Return error type.

Source code in prettyqt\network\networkreply.py
def get_error(self) -> NetworkErrorStr:
    """Return error type.

    Returns:
        error type
    """
    return NETWORK_ERROR.inverse[self.error()]