Home / Function/ request() — requests Function Reference

request() — requests Function Reference

Architecture documentation for the request() function in sessions.py from the requests codebase.

Function python CoreAPI SessionLifecycle calls 4 called by 8

Entity Profile

Dependency Diagram

graph TD
  71102afa_b9d8_769c_e8b8_1db9a083fa11["request()"]
  b4dad953_9227_8b3f_4041_3f8f1f9f0b29["Session"]
  71102afa_b9d8_769c_e8b8_1db9a083fa11 -->|defined in| b4dad953_9227_8b3f_4041_3f8f1f9f0b29
  e5f3beee_4f0d_bcf5_4af9_52d8658ab65f["get()"]
  e5f3beee_4f0d_bcf5_4af9_52d8658ab65f -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  9871a555_0da1_d5d5_d97d_66898dd8de45["options()"]
  9871a555_0da1_d5d5_d97d_66898dd8de45 -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  781cb9a0_9aa4_57cf_36f3_47230c76fd28["head()"]
  781cb9a0_9aa4_57cf_36f3_47230c76fd28 -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  84326225_e63b_ea25_d8a2_1582fe90acf9["post()"]
  84326225_e63b_ea25_d8a2_1582fe90acf9 -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  52502a1e_98bf_2e99_032b_c4c4a3af6e1d["put()"]
  52502a1e_98bf_2e99_032b_c4c4a3af6e1d -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  939bd7e3_2435_7109_47cf_270053aae7ef["patch()"]
  939bd7e3_2435_7109_47cf_270053aae7ef -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  11a6f326_6158_3e46_ecf2_4c2601ddef9b["delete()"]
  11a6f326_6158_3e46_ecf2_4c2601ddef9b -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  22824d7d_af0c_f593_6513_06ba28a4fc56["send()"]
  22824d7d_af0c_f593_6513_06ba28a4fc56 -->|calls| 71102afa_b9d8_769c_e8b8_1db9a083fa11
  a4eb532d_c481_9e3e_ad07_8d203ffafd2d["prepare_request()"]
  71102afa_b9d8_769c_e8b8_1db9a083fa11 -->|calls| a4eb532d_c481_9e3e_ad07_8d203ffafd2d
  a33f5af9_f802_7d68_8e3b_ee865096e920["merge_environment_settings()"]
  71102afa_b9d8_769c_e8b8_1db9a083fa11 -->|calls| a33f5af9_f802_7d68_8e3b_ee865096e920
  22824d7d_af0c_f593_6513_06ba28a4fc56["send()"]
  71102afa_b9d8_769c_e8b8_1db9a083fa11 -->|calls| 22824d7d_af0c_f593_6513_06ba28a4fc56
  0aace64c_6424_62be_3052_5ea0e8ae90d3["update()"]
  71102afa_b9d8_769c_e8b8_1db9a083fa11 -->|calls| 0aace64c_6424_62be_3052_5ea0e8ae90d3
  style 71102afa_b9d8_769c_e8b8_1db9a083fa11 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/requests/sessions.py lines 501–592

    def request(
        self,
        method,
        url,
        params=None,
        data=None,
        headers=None,
        cookies=None,
        files=None,
        auth=None,
        timeout=None,
        allow_redirects=True,
        proxies=None,
        hooks=None,
        stream=None,
        verify=None,
        cert=None,
        json=None,
    ):
        """Constructs a :class:`Request <Request>`, prepares it and sends it.
        Returns :class:`Response <Response>` object.

        :param method: method for the new :class:`Request` object.
        :param url: URL for the new :class:`Request` object.
        :param params: (optional) Dictionary or bytes to be sent in the query
            string for the :class:`Request`.
        :param data: (optional) Dictionary, list of tuples, bytes, or file-like
            object to send in the body of the :class:`Request`.
        :param json: (optional) json to send in the body of the
            :class:`Request`.
        :param headers: (optional) Dictionary of HTTP Headers to send with the
            :class:`Request`.
        :param cookies: (optional) Dict or CookieJar object to send with the
            :class:`Request`.
        :param files: (optional) Dictionary of ``'filename': file-like-objects``
            for multipart encoding upload.
        :param auth: (optional) Auth tuple or callable to enable
            Basic/Digest/Custom HTTP Auth.
        :param timeout: (optional) How many seconds to wait for the server to send
            data before giving up, as a float, or a :ref:`(connect timeout,
            read timeout) <timeouts>` tuple.
        :type timeout: float or tuple
        :param allow_redirects: (optional) Set to True by default.
        :type allow_redirects: bool
        :param proxies: (optional) Dictionary mapping protocol or protocol and
            hostname to the URL of the proxy.
        :param hooks: (optional) Dictionary mapping hook name to one event or
            list of events, event must be callable.
        :param stream: (optional) whether to immediately download the response
            content. Defaults to ``False``.
        :param verify: (optional) Either a boolean, in which case it controls whether we verify
            the server's TLS certificate, or a string, in which case it must be a path
            to a CA bundle to use. Defaults to ``True``. When set to
            ``False``, requests will accept any TLS certificate presented by
            the server, and will ignore hostname mismatches and/or expired
            certificates, which will make your application vulnerable to
            man-in-the-middle (MitM) attacks. Setting verify to ``False``
            may be useful during local development or testing.
        :param cert: (optional) if String, path to ssl client cert file (.pem).
            If Tuple, ('cert', 'key') pair.
        :rtype: requests.Response
        """
        # Create the Request.
        req = Request(
            method=method.upper(),
            url=url,
            headers=headers,
            files=files,
            data=data or {},
            json=json,
            params=params or {},
            auth=auth,
            cookies=cookies,
            hooks=hooks,
        )
        prep = self.prepare_request(req)

        proxies = proxies or {}

        settings = self.merge_environment_settings(
            prep.url, proxies, stream, verify, cert

Domain

Subdomains

Frequently Asked Questions

What does request() do?
request() is a function in the requests codebase, defined in src/requests/sessions.py.
Where is request() defined?
request() is defined in src/requests/sessions.py at line 501.
What does request() call?
request() calls 4 function(s): merge_environment_settings, prepare_request, send, update.
What calls request()?
request() is called by 8 function(s): delete, get, head, options, patch, post, put, send.

Analyze Your Own Codebase

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

Try Supermodel Free