Source code for human_requests.tools.http_utils

"""
HTTP-helpers (cookie logic, charset, Playwright ↔ Curl adapters).
"""

from __future__ import annotations

from http.cookies import SimpleCookie
from typing import Any, Iterable, Mapping, Tuple
from urllib.parse import SplitResult

from ..abstraction.cookies import Cookie

# ───────────────────── RFC 6265 helpers ──────────────────────────────






# ───────────────────── charset helper ────────────────────────────────


[docs] def guess_encoding(headers: Mapping[str, str]) -> str: ctype = headers.get("content-type", "") if "charset=" in ctype: return ctype.split("charset=", 1)[1].split(";", 1)[0].strip(" \"'") or "utf-8" return "utf-8"
# ───────────────────── Cookie → Header ─────────────────────────────── # ───────────────────── Set-Cookie → Cookie objects ───────────────────