Home / Class/ MockResponse Class — requests Architecture

MockResponse Class — requests Architecture

Architecture documentation for the MockResponse class in cookies.py from the requests codebase.

Entity Profile

Dependency Diagram

graph TD
  7a2803d8_8aa2_6bba_28a2_c94b7f160f35["MockResponse"]
  270696ff_2a4f_ef5b_92e8_33a79e68a2d8["cookies.py"]
  7a2803d8_8aa2_6bba_28a2_c94b7f160f35 -->|defined in| 270696ff_2a4f_ef5b_92e8_33a79e68a2d8
  d18984c2_6094_864d_2296_9600363fdf74["__init__()"]
  7a2803d8_8aa2_6bba_28a2_c94b7f160f35 -->|method| d18984c2_6094_864d_2296_9600363fdf74
  333dbbdb_d08c_fdd7_456f_04ef7da81718["info()"]
  7a2803d8_8aa2_6bba_28a2_c94b7f160f35 -->|method| 333dbbdb_d08c_fdd7_456f_04ef7da81718
  49b8cf9f_bcdc_e66d_87f5_bb82ac9c9d89["getheaders()"]
  7a2803d8_8aa2_6bba_28a2_c94b7f160f35 -->|method| 49b8cf9f_bcdc_e66d_87f5_bb82ac9c9d89

Relationship Graph

Source Code

src/requests/cookies.py lines 103–121

class MockResponse:
    """Wraps a `httplib.HTTPMessage` to mimic a `urllib.addinfourl`.

    ...what? Basically, expose the parsed HTTP headers from the server response
    the way `http.cookiejar` expects to see them.
    """

    def __init__(self, headers):
        """Make a MockResponse for `cookiejar` to read.

        :param headers: a httplib.HTTPMessage or analogous carrying the headers
        """
        self._headers = headers

    def info(self):
        return self._headers

    def getheaders(self, name):
        self._headers.getheaders(name)

Domain

Frequently Asked Questions

What is the MockResponse class?
MockResponse is a class in the requests codebase, defined in src/requests/cookies.py.
Where is MockResponse defined?
MockResponse is defined in src/requests/cookies.py at line 103.

Analyze Your Own Codebase

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

Try Supermodel Free