| 119 | """ |
| 120 | |
| 121 | def __init__( |
| 122 | self, |
| 123 | remote_server_addr: str, |
| 124 | keep_alive: bool | None = True, |
| 125 | proxy: Proxy | None = None, |
| 126 | ignore_certificates: bool | None = False, |
| 127 | init_args_for_pool_manager: dict | None = None, |
| 128 | timeout: int | None = None, |
| 129 | ca_certs: str | None = None, |
| 130 | username: str | None = None, |
| 131 | password: str | None = None, |
| 132 | auth_type: AuthType | None = AuthType.BASIC, |
| 133 | token: str | None = None, |
| 134 | user_agent: str | None = None, |
| 135 | extra_headers: dict | None = None, |
| 136 | websocket_timeout: float | None = 30.0, |
| 137 | websocket_interval: float | None = None, |
| 138 | websocket_max_message_size: int | None = None, |
| 139 | ) -> None: |
| 140 | self.remote_server_addr = remote_server_addr |
| 141 | self.keep_alive = keep_alive |
| 142 | self.proxy = Proxy(raw={"proxyType": ProxyType.SYSTEM}) if proxy is None else proxy |
| 143 | self.ignore_certificates = ignore_certificates |
| 144 | # Copy caller-owned dicts so two ClientConfigs (or the caller's own dict) can't be |
| 145 | # aliased into one another and mutated in place. |
| 146 | self.init_args_for_pool_manager = dict(init_args_for_pool_manager or {}) |
| 147 | self.timeout = socket.getdefaulttimeout() if timeout is None else timeout |
| 148 | self.username = username |
| 149 | self.password = password |
| 150 | self.auth_type = auth_type |
| 151 | self.token = token |
| 152 | self.user_agent = user_agent |
| 153 | self.extra_headers = dict(extra_headers) if extra_headers is not None else None |
| 154 | self.websocket_timeout = websocket_timeout |
| 155 | if websocket_interval is not None: |
| 156 | warnings.warn( |
| 157 | "websocket_interval does nothing and will be removed", |
| 158 | DeprecationWarning, |
| 159 | stacklevel=2, |
| 160 | ) |
| 161 | self._websocket_interval = websocket_interval |
| 162 | self.websocket_max_message_size = websocket_max_message_size |
| 163 | |
| 164 | self.ca_certs = ( |
| 165 | (os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where()) |
| 166 | if ca_certs is None |
| 167 | else ca_certs |
| 168 | ) |
| 169 | |
| 170 | def reset_timeout(self) -> None: |
| 171 | """Resets the timeout to the default value of socket.""" |