__init__() — requests Function Reference
Architecture documentation for the __init__() function in sessions.py from the requests codebase.
Entity Profile
Dependency Diagram
graph TD 9e3b60ed_3668_f4e9_fa2a_9db7ae000c2e["__init__()"] b4dad953_9227_8b3f_4041_3f8f1f9f0b29["Session"] 9e3b60ed_3668_f4e9_fa2a_9db7ae000c2e -->|defined in| b4dad953_9227_8b3f_4041_3f8f1f9f0b29 9c6f5171_db61_9fae_2377_5daac75619a3["mount()"] 9e3b60ed_3668_f4e9_fa2a_9db7ae000c2e -->|calls| 9c6f5171_db61_9fae_2377_5daac75619a3 23816a5f_d797_e077_ac99_827b59b52f7b["default_headers()"] 9e3b60ed_3668_f4e9_fa2a_9db7ae000c2e -->|calls| 23816a5f_d797_e077_ac99_827b59b52f7b 2254e69c_6485_b746_f87f_e79515085198["default_hooks()"] 9e3b60ed_3668_f4e9_fa2a_9db7ae000c2e -->|calls| 2254e69c_6485_b746_f87f_e79515085198 fad58eac_0316_2b83_52d3_1a1829c12c66["cookiejar_from_dict()"] 9e3b60ed_3668_f4e9_fa2a_9db7ae000c2e -->|calls| fad58eac_0316_2b83_52d3_1a1829c12c66 style 9e3b60ed_3668_f4e9_fa2a_9db7ae000c2e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
src/requests/sessions.py lines 391–450
def __init__(self):
#: A case-insensitive dictionary of headers to be sent on each
#: :class:`Request <Request>` sent from this
#: :class:`Session <Session>`.
self.headers = default_headers()
#: Default Authentication tuple or object to attach to
#: :class:`Request <Request>`.
self.auth = None
#: Dictionary mapping protocol or protocol and host to the URL of the proxy
#: (e.g. {'http': 'foo.bar:3128', 'http://host.name': 'foo.bar:4012'}) to
#: be used on each :class:`Request <Request>`.
self.proxies = {}
#: Event-handling hooks.
self.hooks = default_hooks()
#: Dictionary of querystring data to attach to each
#: :class:`Request <Request>`. The dictionary values may be lists for
#: representing multivalued query parameters.
self.params = {}
#: Stream response content default.
self.stream = False
#: SSL Verification default.
#: Defaults to `True`, requiring requests to verify the TLS certificate at the
#: remote end.
#: If verify is 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.
#: Only set this to `False` for testing.
self.verify = True
#: SSL client certificate default, if String, path to ssl client
#: cert file (.pem). If Tuple, ('cert', 'key') pair.
self.cert = None
#: Maximum number of redirects allowed. If the request exceeds this
#: limit, a :class:`TooManyRedirects` exception is raised.
#: This defaults to requests.models.DEFAULT_REDIRECT_LIMIT, which is
#: 30.
self.max_redirects = DEFAULT_REDIRECT_LIMIT
#: Trust environment settings for proxy configuration, default
#: authentication and similar.
self.trust_env = True
#: A CookieJar containing all currently outstanding cookies set on this
#: session. By default it is a
#: :class:`RequestsCookieJar <requests.cookies.RequestsCookieJar>`, but
#: may be any other ``cookielib.CookieJar`` compatible object.
self.cookies = cookiejar_from_dict({})
# Default connection adapters.
self.adapters = OrderedDict()
self.mount("https://", HTTPAdapter())
self.mount("http://", HTTPAdapter())
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the requests codebase, defined in src/requests/sessions.py.
Where is __init__() defined?
__init__() is defined in src/requests/sessions.py at line 391.
What does __init__() call?
__init__() calls 4 function(s): cookiejar_from_dict, default_headers, default_hooks, mount.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free