|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | import uuid |
16 | | -from typing import TYPE_CHECKING, Any, Dict, Optional, Union |
| 16 | +from typing import TYPE_CHECKING, Any, Dict, Optional |
17 | 17 |
|
18 | | -import urllib3 |
19 | 18 | from selenium.webdriver.remote.remote_connection import RemoteConnection |
20 | 19 |
|
21 | 20 | from appium.common.helper import library_version |
|
30 | 29 | class AppiumConnection(RemoteConnection): |
31 | 30 | _proxy_url: Optional[str] |
32 | 31 |
|
33 | | - user_agent = f'{PREFIX_HEADER}{library_version()} ({RemoteConnection.user_agent})' |
34 | | - |
35 | | - def __init__( |
36 | | - self, |
37 | | - remote_server_addr: str, |
38 | | - keep_alive: bool = False, |
39 | | - ignore_proxy: Optional[bool] = False, |
40 | | - init_args_for_pool_manager: Union[Dict[str, Any], None] = None, |
41 | | - ): |
42 | | - # Need to call before super().__init__ in order to pass arguments for the pool manager in the super. |
43 | | - self._init_args_for_pool_manager = init_args_for_pool_manager or {} |
44 | | - |
45 | | - super().__init__(remote_server_addr, keep_alive=keep_alive, ignore_proxy=ignore_proxy) |
46 | | - |
47 | | - def _get_connection_manager(self) -> Union[urllib3.PoolManager, urllib3.ProxyManager]: |
48 | | - # https://github.com/SeleniumHQ/selenium/blob/0e0194b0e52a34e7df4b841f1ed74506beea5c3e/py/selenium/webdriver/remote/remote_connection.py#L134 |
49 | | - pool_manager_init_args = {'timeout': self.get_timeout()} |
50 | | - |
51 | | - if self._ca_certs: |
52 | | - pool_manager_init_args['cert_reqs'] = 'CERT_REQUIRED' |
53 | | - pool_manager_init_args['ca_certs'] = self._ca_certs |
54 | | - else: |
55 | | - # This line is necessary to disable certificate verification |
56 | | - pool_manager_init_args['cert_reqs'] = 'CERT_NONE' |
57 | | - |
58 | | - pool_manager_init_args.update(self._init_args_for_pool_manager) |
59 | | - |
60 | | - if self._proxy_url: |
61 | | - if self._proxy_url.lower().startswith('sock'): |
62 | | - from urllib3.contrib.socks import SOCKSProxyManager |
63 | | - |
64 | | - return SOCKSProxyManager(self._proxy_url, **pool_manager_init_args) |
65 | | - if self._identify_http_proxy_auth(): |
66 | | - self._proxy_url, self._basic_proxy_auth = self._separate_http_proxy_auth() |
67 | | - pool_manager_init_args['proxy_headers'] = urllib3.make_headers(proxy_basic_auth=self._basic_proxy_auth) |
68 | | - return urllib3.ProxyManager(self._proxy_url, **pool_manager_init_args) |
69 | | - |
70 | | - return urllib3.PoolManager(**pool_manager_init_args) |
| 32 | + RemoteConnection.user_agent = f'{PREFIX_HEADER}{library_version()} ({RemoteConnection.user_agent})' |
71 | 33 |
|
72 | 34 | @classmethod |
73 | 35 | def get_remote_connection_headers(cls, parsed_url: 'ParseResult', keep_alive: bool = True) -> Dict[str, Any]: |
|
0 commit comments