Home / Function/ __init__() — requests Function Reference

__init__() — requests Function Reference

Architecture documentation for the __init__() function in models.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  b47cdd7b_1bee_c465_e1f8_c3fa479afe6c["__init__()"]
  eb32847e_3797_d01a_6e44_345e9ea7e251["Response"]
  b47cdd7b_1bee_c465_e1f8_c3fa479afe6c -->|defined in| eb32847e_3797_d01a_6e44_345e9ea7e251
  fad58eac_0316_2b83_52d3_1a1829c12c66["cookiejar_from_dict()"]
  b47cdd7b_1bee_c465_e1f8_c3fa479afe6c -->|calls| fad58eac_0316_2b83_52d3_1a1829c12c66
  style b47cdd7b_1bee_c465_e1f8_c3fa479afe6c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/models.py lines 660–705

    def __init__(self):
        self._content = False
        self._content_consumed = False
        self._next = None

        #: Integer Code of responded HTTP Status, e.g. 404 or 200.
        self.status_code = None

        #: Case-insensitive Dictionary of Response Headers.
        #: For example, ``headers['content-encoding']`` will return the
        #: value of a ``'Content-Encoding'`` response header.
        self.headers = CaseInsensitiveDict()

        #: File-like object representation of response (for advanced usage).
        #: Use of ``raw`` requires that ``stream=True`` be set on the request.
        #: This requirement does not apply for use internally to Requests.
        self.raw = None

        #: Final URL location of Response.
        self.url = None

        #: Encoding to decode with when accessing r.text.
        self.encoding = None

        #: A list of :class:`Response <Response>` objects from
        #: the history of the Request. Any redirect responses will end
        #: up here. The list is sorted from the oldest to the most recent request.
        self.history = []

        #: Textual reason of responded HTTP Status, e.g. "Not Found" or "OK".
        self.reason = None

        #: A CookieJar of Cookies the server sent back.
        self.cookies = cookiejar_from_dict({})

        #: The amount of time elapsed between sending the request
        #: and the arrival of the response (as a timedelta).
        #: This property specifically measures the time taken between sending
        #: the first byte of the request and finishing parsing the headers. It
        #: is therefore unaffected by consuming the response content or the
        #: value of the ``stream`` keyword argument.
        self.elapsed = datetime.timedelta(0)

        #: The :class:`PreparedRequest <PreparedRequest>` object to which this
        #: is a response.
        self.request = None

Domain

Subdomains

Frequently Asked Questions

What does __init__() do?
__init__() is a function in the requests codebase, defined in src/requests/models.py.
Where is __init__() defined?
__init__() is defined in src/requests/models.py at line 660.
What does __init__() call?
__init__() calls 1 function(s): cookiejar_from_dict.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free