MCPcopy
hub / github.com/encode/httpx / __init__

Method __init__

httpx/_client.py:639–716  ·  httpx/_client.py::Client.__init__
(
        self,
        *,
        auth: AuthTypes | None = None,
        params: QueryParamTypes | None = None,
        headers: HeaderTypes | None = None,
        cookies: CookieTypes | None = None,
        verify: ssl.SSLContext | str | bool = True,
        cert: CertTypes | None = None,
        trust_env: bool = True,
        http1: bool = True,
        http2: bool = False,
        proxy: ProxyTypes | None = None,
        mounts: None | (typing.Mapping[str, BaseTransport | None]) = None,
        timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
        follow_redirects: bool = False,
        limits: Limits = DEFAULT_LIMITS,
        max_redirects: int = DEFAULT_MAX_REDIRECTS,
        event_hooks: None | (typing.Mapping[str, list[EventHook]]) = None,
        base_url: URL | str = "",
        transport: BaseTransport | None = None,
        default_encoding: str | typing.Callable[[bytes], str] = "utf-8",
    )

Source from the content-addressed store, hash-verified

637 class="st">"""
638
639 def __init__(
640 self,
641 *,
642 auth: AuthTypes | None = None,
643 params: QueryParamTypes | None = None,
644 headers: HeaderTypes | None = None,
645 cookies: CookieTypes | None = None,
646 verify: ssl.SSLContext | str | bool = True,
647 cert: CertTypes | None = None,
648 trust_env: bool = True,
649 http1: bool = True,
650 http2: bool = False,
651 proxy: ProxyTypes | None = None,
652 mounts: None | (typing.Mapping[str, BaseTransport | None]) = None,
653 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
654 follow_redirects: bool = False,
655 limits: Limits = DEFAULT_LIMITS,
656 max_redirects: int = DEFAULT_MAX_REDIRECTS,
657 event_hooks: None | (typing.Mapping[str, list[EventHook]]) = None,
658 base_url: URL | str = class="st">"",
659 transport: BaseTransport | None = None,
660 default_encoding: str | typing.Callable[[bytes], str] = class="st">"utf-8",
661 ) -> None:
662 super().__init__(
663 auth=auth,
664 params=params,
665 headers=headers,
666 cookies=cookies,
667 timeout=timeout,
668 follow_redirects=follow_redirects,
669 max_redirects=max_redirects,
670 event_hooks=event_hooks,
671 base_url=base_url,
672 trust_env=trust_env,
673 default_encoding=default_encoding,
674 )
675
676 if http2:
677 try:
678 import h2 class="cm"># noqa
679 except ImportError: class="cm"># pragma: no cover
680 raise ImportError(
681 class="st">"Using http2=True, but the &class="cm">#x27;h2' package is not installed. "
682 class="st">"Make sure to install httpx using `pip install httpx[http2]`."
683 ) from None
684
685 allow_env_proxies = trust_env and transport is None
686 proxy_map = self._get_proxy_map(proxy, allow_env_proxies)
687
688 self._transport = self._init_transport(
689 verify=verify,
690 cert=cert,
691 trust_env=trust_env,
692 http1=http1,
693 http2=http2,
694 limits=limits,
695 transport=transport,
696 )

Callers 1

__init__Method · 0.45

Calls 6

_init_transportMethod · 0.95
_init_proxy_transportMethod · 0.95
URLPatternClass · 0.85
_get_proxy_mapMethod · 0.80
itemsMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected