# Path: src/amcrest/config.py
# KEEPALIVE_COUNT = 5
# 
# KEEPALIVE_IDLE = 20
# 
# KEEPALIVE_INTERVAL = 10
# 
# MAX_RETRY_HTTP_CONNECTION = 3
# 
# TIMEOUT_HTTP_PROTOCOL = 6.05
# 
# Path: src/amcrest/exceptions.py
# class CommError(AmcrestError):
#     """A communication error occurred."""
# 
# class LoginError(AmcrestError):
#     """A login error occurred."""
# 
# Path: src/amcrest/utils.py
# def clean_url(url: str) -> str:
#     host = re.sub(r"^http[s]?://", "", url, flags=re.IGNORECASE)
#     host = re.sub(r"/$", "", host)
#     return host
# 
# def pretty(value: str, delimiter: str = "=") -> str:
#     """Format string key=value."""
#     return value.strip().rpartition(delimiter)[2]


import asyncio
import logging
import re
import socket
import threading
import httpx
import requests
from contextlib import asynccontextmanager
from typing import AsyncIterator, Optional, Tuple, Union
from requests.adapters import HTTPAdapter
from urllib3.connection import HTTPConnection
from .config import (
    KEEPALIVE_COUNT,
    KEEPALIVE_IDLE,
    KEEPALIVE_INTERVAL,
    MAX_RETRY_HTTP_CONNECTION,
    TIMEOUT_HTTP_PROTOCOL,
)
from .exceptions import CommError, LoginError
from .utils import clean_url, pretty
        user: str,
        password: str,
        *,
        verbose: bool = True,
        protocol: str = "http",
        ssl_verify: bool = True,
        retries_connection: Optional[int] = None,
        timeout_protocol: TimeoutT = None,
    ) -> None:
        self._token_lock = threading.Lock()
        try:
            self._async_token_lock: Optional[asyncio.Lock] = asyncio.Lock()
        except RuntimeError:
            self._async_token_lock = None
        self._cmd_id_lock = threading.Lock()
        self._cmd_id = 0
        self._host = clean_url(host)
        self._port = port
        self._user = user
        self._password = password
        self._verbose = verbose
        self._protocol = protocol
        self._verify = ssl_verify
        self._base_url = self.__base_url()

        self._retries_default = (
            retries_connection
            if retries_connection is not None
            else MAX_RETRY_HTTP_CONNECTION
        )

# Path: src/amcrest/config.py
# KEEPALIVE_COUNT = 5
# 
# KEEPALIVE_IDLE = 20
# 
# KEEPALIVE_INTERVAL = 10
# 
# MAX_RETRY_HTTP_CONNECTION = 3
# 
# TIMEOUT_HTTP_PROTOCOL = 6.05
# 
# Path: src/amcrest/exceptions.py
# class CommError(AmcrestError):
#     """A communication error occurred."""
# 
# class LoginError(AmcrestError):
#     """A login error occurred."""
# 
# Path: src/amcrest/utils.py
# def clean_url(url: str) -> str:
#     host = re.sub(r"^http[s]?://", "", url, flags=re.IGNORECASE)
#     host = re.sub(r"/$", "", host)
#     return host
# 
# def pretty(value: str, delimiter: str = "=") -> str:
#     """Format string key=value."""
#     return value.strip().rpartition(delimiter)[2]


# Path: src/amcrest/http.py
import asyncio
import logging
import re
import socket
import threading
import httpx
import requests
from contextlib import asynccontextmanager
from typing import AsyncIterator, Optional, Tuple, Union
from requests.adapters import HTTPAdapter
from urllib3.connection import HTTPConnection
from .config import (
    KEEPALIVE_COUNT,
    KEEPALIVE_IDLE,
    KEEPALIVE_INTERVAL,
    MAX_RETRY_HTTP_CONNECTION,
    TIMEOUT_HTTP_PROTOCOL,
)
from .exceptions import CommError, LoginError
from .utils import clean_url, pretty

        user: str,
        password: str,
        *,
        verbose: bool = True,
        protocol: str = "http",
        ssl_verify: bool = True,
        retries_connection: Optional[int] = None,
        timeout_protocol: TimeoutT = None,
    ) -> None:
        self._token_lock = threading.Lock()
        try:
            self._async_token_lock: Optional[asyncio.Lock] = asyncio.Lock()
        except RuntimeError:
            self._async_token_lock = None
        self._cmd_id_lock = threading.Lock()
        self._cmd_id = 0
        self._host = clean_url(host)
        self._port = port
        self._user = user
        self._password = password
        self._verbose = verbose
        self._protocol = protocol
        self._verify = ssl_verify
        self._base_url = self.__base_url()

        self._retries_default = (
            retries_connection
            if retries_connection is not None
            else MAX_RETRY_HTTP_CONNECTION
        )

        self._timeout_default = timeout_protocol or TIMEOUT_HTTP_PROTOCOL