MCPcopy Index your code
hub / github.com/appium/python-client / AppiumConnection

Class AppiumConnection

appium/webdriver/appium_connection.py:38–65  ·  view source on GitHub ↗

A subclass of selenium.webdriver.remote.remote_connection.Remoteconnection. The changes are * The default user agent * Adds 'X-Idempotency-Key' header in a new session request to avoid proceeding the same request multiple times in the Appium server side. * https://

Source from the content-addressed store, hash-verified

36
37
38class AppiumConnection(RemoteConnection):
39 """
40 A subclass of selenium.webdriver.remote.remote_connection.Remoteconnection.
41
42 The changes are
43
44 * The default user agent
45 * Adds 'X-Idempotency-Key' header in a new session request to avoid proceeding
46 the same request multiple times in the Appium server side.
47 * https://github.com/appium/appium-base-driver/pull/400
48 """
49
50 user_agent = f'{PREFIX_HEADER}{library_version()} ({RemoteConnection.user_agent})'
51 extra_headers = {}
52
53 @classmethod
54 def get_remote_connection_headers(cls, parsed_url: 'ParseResult', keep_alive: bool = True) -> Dict[str, Any]:
55 """Override get_remote_connection_headers in RemoteConnection to control the extra headers.
56 This method will be used in sending a request method in this class.
57 """
58
59 if parsed_url.path.endswith('/session'):
60 # https://github.com/appium/appium-base-driver/pull/400
61 cls.extra_headers[HEADER_IDEMOTENCY_KEY] = str(uuid.uuid4())
62 else:
63 cls.extra_headers = _get_new_headers(HEADER_IDEMOTENCY_KEY, cls.extra_headers)
64
65 return {**super().get_remote_connection_headers(parsed_url, keep_alive=keep_alive), **cls.extra_headers}

Calls 1

library_versionFunction · 0.90