Home / File/ utils.py — requests Source File

utils.py — requests Source File

Architecture documentation for utils.py, a python file in the requests codebase. 30 imports, 4 dependents.

File python CoreAPI VerbHandlers 30 imports 4 dependents 41 functions

Entity Profile

Dependency Diagram

graph LR
  2c39b9da_e317_5e6c_bbac_8362bac2110c["utils.py"]
  afade041_1d0e_4e62_968a_7b5fb4c150b5["afade041:1d0e:4e62:968a:7b5fb4c150b5"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> afade041_1d0e_4e62_968a_7b5fb4c150b5
  616c96e3_864c_f2bb_a2a3_856a02063a22["__version__.py"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> 616c96e3_864c_f2bb_a2a3_856a02063a22
  ad9103ba_2c26_1ff0_c67d_e7f70c6f108c["_internal_utils.py"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> ad9103ba_2c26_1ff0_c67d_e7f70c6f108c
  0ab29509_59a1_1f68_fae2_146376240019["to_native_string"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> 0ab29509_59a1_1f68_fae2_146376240019
  655589d9_9504_8132_6277_d047dcd65486["compat.py"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> 655589d9_9504_8132_6277_d047dcd65486
  a3d70d90_bb90_c2f8_2cbe_09463ba10d3d["is_urllib3_1"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> a3d70d90_bb90_c2f8_2cbe_09463ba10d3d
  270696ff_2a4f_ef5b_92e8_33a79e68a2d8["cookies.py"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> 270696ff_2a4f_ef5b_92e8_33a79e68a2d8
  fad58eac_0316_2b83_52d3_1a1829c12c66["cookiejar_from_dict"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> fad58eac_0316_2b83_52d3_1a1829c12c66
  f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8["exceptions.py"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8
  eb6b754a_1900_5936_937a_ef01e9e4e6e7["FileModeWarning"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> eb6b754a_1900_5936_937a_ef01e9e4e6e7
  5f5c4495_052d_a9c8_2212_6ab9998c0ab5["InvalidHeader"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> 5f5c4495_052d_a9c8_2212_6ab9998c0ab5
  b50a24e0_eb72_4e23_66de_6c500b639532["InvalidURL"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> b50a24e0_eb72_4e23_66de_6c500b639532
  1acb95ca_42ed_5e1e_3c56_26ad82925afd["UnrewindableBodyError"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> 1acb95ca_42ed_5e1e_3c56_26ad82925afd
  989bc203_d602_fe82_ab02_7d12fb621eee["structures.py"]
  2c39b9da_e317_5e6c_bbac_8362bac2110c --> 989bc203_d602_fe82_ab02_7d12fb621eee
  style 2c39b9da_e317_5e6c_bbac_8362bac2110c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""
requests.utils
~~~~~~~~~~~~~~

This module provides utility functions that are used within Requests
that are also useful for external consumption.
"""

import codecs
import contextlib
import io
import os
import re
import socket
import struct
import sys
import tempfile
import warnings
import zipfile
from collections import OrderedDict

from urllib3.util import make_headers, parse_url

from . import certs
from .__version__ import __version__

# to_native_string is unused here, but imported here for backwards compatibility
from ._internal_utils import (  # noqa: F401
    _HEADER_VALIDATORS_BYTE,
    _HEADER_VALIDATORS_STR,
    HEADER_VALIDATORS,
    to_native_string,
)
from .compat import (
    Mapping,
    basestring,
    bytes,
    getproxies,
    getproxies_environment,
    integer_types,
    is_urllib3_1,
    proxy_bypass,
    proxy_bypass_environment,
    quote,
    str,
    unquote,
    urlparse,
    urlunparse,
)
from .compat import parse_http_list as _parse_list_header
from .cookies import cookiejar_from_dict
from .exceptions import (
    FileModeWarning,
    InvalidHeader,
    InvalidURL,
    UnrewindableBodyError,
)
from .structures import CaseInsensitiveDict

NETRC_FILES = (".netrc", "_netrc")
// ... (1025 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does utils.py do?
utils.py is a source file in the requests codebase, written in python. It belongs to the CoreAPI domain, VerbHandlers subdomain.
What functions are defined in utils.py?
utils.py defines 41 function(s): _parse_content_type_header, _validate_header_part, add_dict_to_cookiejar, address_in_network, atomic_open, check_header_validity, default_headers, default_user_agent, dict_from_cookiejar, dict_to_sequence, and 31 more.
What does utils.py depend on?
utils.py imports 30 module(s): CaseInsensitiveDict, FileModeWarning, InvalidHeader, InvalidURL, UnrewindableBodyError, __version__.py, _internal_utils.py, afade041:1d0e:4e62:968a:7b5fb4c150b5, and 22 more.
What files import utils.py?
utils.py is imported by 4 file(s): adapters.py, auth.py, models.py, sessions.py.
Where is utils.py in the architecture?
utils.py is located at src/requests/utils.py (domain: CoreAPI, subdomain: VerbHandlers, directory: src/requests).

Analyze Your Own Codebase

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

Try Supermodel Free