Skip to content

Commit 3509353

Browse files
committed
get new headers
1 parent cddeaa1 commit 3509353

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

appium/webdriver/appium_connection.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@
2828
_HEADER_IDEMOTENCY_KEY = 'X-Idempotency-Key'
2929

3030

31+
def _get_new_headers(key: str, headers: dict[str, str]) -> dict[str, str]:
32+
"""Return a new dictionary of heafers without the given key.
33+
The key match is case-insensitive."""
34+
new_headers = dict()
35+
36+
key = key.lower()
37+
for k, v in headers.items():
38+
if k.lower() == key:
39+
continue
40+
new_headers[k] = v
41+
return new_headers
42+
43+
3144
class AppiumConnection(RemoteConnection):
3245
"""
3346
A subclass of selenium.webdriver.remote.remote_connection.Remoteconnection.
@@ -51,7 +64,7 @@ def get_remote_connection_headers(cls, parsed_url: 'ParseResult', keep_alive: bo
5164
if parsed_url.path.endswith('/session'):
5265
# https://github.com/appium/appium-base-driver/pull/400
5366
cls.extra_headers[_HEADER_IDEMOTENCY_KEY] = str(uuid.uuid4())
54-
elif _HEADER_IDEMOTENCY_KEY in cls.extra_headers:
55-
del cls.extra_headers[_HEADER_IDEMOTENCY_KEY]
67+
else:
68+
cls.extra_headers = _get_new_headers(_HEADER_IDEMOTENCY_KEY, cls.extra_headers)
5669

5770
return {**super().get_remote_connection_headers(parsed_url, keep_alive=keep_alive), **cls.extra_headers}

0 commit comments

Comments
 (0)