HTTP Response container. Backwards-compatible with :class:`http.client.HTTPResponse` but the response ``body`` is loaded and decoded on-demand when the ``data`` property is accessed. This class is also compatible with the Python standard library's :mod:`io` module, and can hen
| 687 | |
| 688 | |
| 689 | class HTTPResponse(BaseHTTPResponse): |
| 690 | """ |
| 691 | HTTP Response container. |
| 692 | |
| 693 | Backwards-compatible with :class:`http.client.HTTPResponse` but the response ``body`` is |
| 694 | loaded and decoded on-demand when the ``data`` property is accessed. This |
| 695 | class is also compatible with the Python standard library's :mod:`io` |
| 696 | module, and can hence be treated as a readable object in the context of that |
| 697 | framework. |
| 698 | |
| 699 | Extra parameters for behaviour not present in :class:`http.client.HTTPResponse`: |
| 700 | |
| 701 | :param preload_content: |
| 702 | If True, the response's body will be preloaded during construction. |
| 703 | |
| 704 | :param decode_content: |
| 705 | If True, will attempt to decode the body based on the |
| 706 | 'content-encoding' header. |
| 707 | |
| 708 | :param original_response: |
| 709 | When this HTTPResponse wrapper is generated from an :class:`http.client.HTTPResponse` |
| 710 | object, it's convenient to include the original for debug purposes. It's |
| 711 | otherwise unused. |
| 712 | |
| 713 | :param retries: |
| 714 | The retries contains the last :class:`~urllib3.util.retry.Retry` that |
| 715 | was used during the request. |
| 716 | |
| 717 | :param enforce_content_length: |
| 718 | Enforce content length checking. Body returned by server must match |
| 719 | value of Content-Length header, if present. Otherwise, raise error. |
| 720 | """ |
| 721 | |
| 722 | def __init__( |
| 723 | self, |
| 724 | body: _TYPE_BODY = "", |
| 725 | headers: typing.Mapping[str, str] | typing.Mapping[bytes, bytes] | None = None, |
| 726 | status: int = 0, |
| 727 | version: int = 0, |
| 728 | version_string: str = "HTTP/?", |
| 729 | reason: str | None = None, |
| 730 | preload_content: bool = True, |
| 731 | decode_content: bool = True, |
| 732 | original_response: _HttplibHTTPResponse | None = None, |
| 733 | pool: HTTPConnectionPool | None = None, |
| 734 | connection: HTTPConnection | None = None, |
| 735 | msg: _HttplibHTTPMessage | None = None, |
| 736 | retries: Retry | None = None, |
| 737 | enforce_content_length: bool = True, |
| 738 | request_method: str | None = None, |
| 739 | request_url: str | None = None, |
| 740 | auto_close: bool = True, |
| 741 | sock_shutdown: typing.Callable[[int], None] | None = None, |
| 742 | ) -> None: |
| 743 | super().__init__( |
| 744 | headers=headers, |
| 745 | status=status, |
| 746 | version=version, |
no outgoing calls