ChunksAndContentLength (util/request.py)

urllib3 · src/urllib3/util/request.py · python · MIT
auth

Core utilities for constructing HTTP request headers and body handling in urllib3.

# Source: https://github.com/urllib3/urllib3 | License: MIT | Copyright 2008-2020 Andrey Petrov and contributors
# Provided via justclaw.it.com; keep this notice with the code.
from __future__ import annotations

import io
import sys
import typing
from base64 import b64encode
from enum import Enum

from ..exceptions import UnrewindableBodyError
from .util import to_bytes

if typing.TYPE_CHECKING:
    from typing import Final

# Pass as a value within ``headers`` to skip
# emitting some HTTP headers that are added automatically.
# The only headers that are supported are ``Accept-Encoding``,
# ``Host``, and ``User-Agent``.
SKIP_HEADER = "@@@SKIP_HEADER@@@"
SKIPPABLE_HEADERS = frozenset(["accept-encoding", "host", "user-agent"])

ACCEPT_ENCODING = "gzip,deflate"
try:
    try:
        import b

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key