Skip to content

Commit d869172

Browse files
committed
update executor command
1 parent 88ca1e7 commit d869172

File tree

1 file changed

+5
-41
lines changed

1 file changed

+5
-41
lines changed

appium/webdriver/appium_connection.py

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
# limitations under the License.
1414

1515
import uuid
16-
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
16+
from typing import TYPE_CHECKING, Any, Dict, Optional
1717

18-
import urllib3
1918
from selenium.webdriver.remote.remote_connection import RemoteConnection
2019

2120
from appium.common.helper import library_version
@@ -30,51 +29,16 @@
3029
class AppiumConnection(RemoteConnection):
3130
_proxy_url: Optional[str]
3231

33-
def __init__(
34-
self,
35-
remote_server_addr: str,
36-
keep_alive: bool = False,
37-
ignore_proxy: Optional[bool] = False,
38-
init_args_for_pool_manager: Union[Dict[str, Any], None] = None,
39-
):
40-
# Need to call before super().__init__ in order to pass arguments for the pool manager in the super.
41-
self._init_args_for_pool_manager = init_args_for_pool_manager or {}
42-
43-
super().__init__(remote_server_addr, keep_alive=keep_alive, ignore_proxy=ignore_proxy)
44-
45-
def _get_connection_manager(self) -> Union[urllib3.PoolManager, urllib3.ProxyManager]:
46-
# https://github.com/SeleniumHQ/selenium/blob/0e0194b0e52a34e7df4b841f1ed74506beea5c3e/py/selenium/webdriver/remote/remote_connection.py#L134
47-
pool_manager_init_args = {'timeout': self.get_timeout()}
48-
49-
if self._ca_certs:
50-
pool_manager_init_args['cert_reqs'] = 'CERT_REQUIRED'
51-
pool_manager_init_args['ca_certs'] = self._ca_certs
52-
else:
53-
# This line is necessary to disable certificate verification
54-
pool_manager_init_args['cert_reqs'] = 'CERT_NONE'
55-
56-
pool_manager_init_args.update(self._init_args_for_pool_manager)
57-
58-
if self._proxy_url:
59-
if self._proxy_url.lower().startswith('sock'):
60-
from urllib3.contrib.socks import SOCKSProxyManager
61-
62-
return SOCKSProxyManager(self._proxy_url, **pool_manager_init_args)
63-
if self._identify_http_proxy_auth():
64-
self._proxy_url, self._basic_proxy_auth = self._separate_http_proxy_auth()
65-
pool_manager_init_args['proxy_headers'] = urllib3.make_headers(proxy_basic_auth=self._basic_proxy_auth)
66-
return urllib3.ProxyManager(self._proxy_url, **pool_manager_init_args)
67-
68-
return urllib3.PoolManager(**pool_manager_init_args)
32+
RemoteConnection.user_agent = f'{PREFIX_HEADER}{library_version()} ({RemoteConnection.user_agent})'
6933

7034
@classmethod
7135
def get_remote_connection_headers(cls, parsed_url: 'ParseResult', keep_alive: bool = True) -> Dict[str, Any]:
7236
"""Override get_remote_connection_headers in RemoteConnection"""
7337
headers = RemoteConnection.get_remote_connection_headers(parsed_url, keep_alive=keep_alive)
74-
# e.g. appium/0.49 (selenium/3.141.0 (python linux))
75-
headers['User-Agent'] = f'{PREFIX_HEADER}{library_version()} ({headers["User-Agent"]})'
7638
if parsed_url.path.endswith('/session'):
7739
# https://github.com/appium/appium-base-driver/pull/400
78-
headers['X-Idempotency-Key'] = str(uuid.uuid4())
40+
RemoteConnection.extra_headers = {'X-Idempotency-Key': str(uuid.uuid4())}
41+
else:
42+
RemoteConnection.extra_headers = {}
7943

8044
return headers

0 commit comments

Comments
 (0)