MCPcopy Index your code
hub / github.com/nonebot/nonebot2 / __init__

Method __init__

nonebot/drivers/httpx.py:58–106  ·  view source on GitHub ↗
(
        self,
        params: QueryTypes = None,
        headers: HeaderTypes = None,
        cookies: CookieTypes = None,
        version: str | HTTPVersion = HTTPVersion.H11,
        timeout: TimeoutTypes | UnsetType = UNSET,
        proxy: str | None = None,
    )

Source from the content-addressed store, hash-verified

56class Session(HTTPClientSession):
57 @override
58 def __init__(
59 self,
60 params: QueryTypes = None,
61 headers: HeaderTypes = None,
62 cookies: CookieTypes = None,
63 version: str | HTTPVersion = HTTPVersion.H11,
64 timeout: TimeoutTypes | UnsetType = UNSET,
65 proxy: str | None = None,
66 ):
67 self._client: httpx.AsyncClient | None = None
68
69 self._params = (
70 tuple(URL.build(query=params).query.items()) if params is not None else None
71 )
72 self._headers = (
73 tuple(CIMultiDict(headers).items()) if headers is not None else None
74 )
75 self._cookies = Cookies(cookies)
76 self._version = HTTPVersion(version)
77
78 _timeout = None
79 if isinstance(timeout, Timeout):
80 avg_timeout = timeout.total and timeout.total / 4
81 timeout_kwargs: dict[str, float | None] = exclude_unset(
82 {
83 "timeout": avg_timeout,
84 "connect": timeout.connect,
85 "read": timeout.read,
86 }
87 )
88 if timeout_kwargs:
89 _timeout = httpx.Timeout(**timeout_kwargs)
90 elif timeout is not UNSET:
91 _timeout = httpx.Timeout(timeout)
92
93 if _timeout is None:
94 avg_timeout = DEFAULT_TIMEOUT.total and DEFAULT_TIMEOUT.total / 4
95 _timeout = httpx.Timeout(
96 **exclude_unset(
97 {
98 "timeout": avg_timeout,
99 "connect": DEFAULT_TIMEOUT.connect,
100 "read": DEFAULT_TIMEOUT.read,
101 }
102 )
103 )
104
105 self._timeout = _timeout
106 self._proxy = proxy
107
108 @property
109 def client(self) -> httpx.AsyncClient:

Callers

nothing calls this directly

Calls 4

CookiesClass · 0.90
exclude_unsetFunction · 0.90
HTTPVersionClass · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected