From 1fcf34c395da583f7a0350446b097dfff4b88adc Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Fri, 10 Apr 2020 21:47:17 +0200 Subject: [PATCH] feat: Add idempotency key header to create session requests --- appium/webdriver/appium_connection.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/appium/webdriver/appium_connection.py b/appium/webdriver/appium_connection.py index 719923fd..9b7218dd 100644 --- a/appium/webdriver/appium_connection.py +++ b/appium/webdriver/appium_connection.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import uuid + from selenium.webdriver.remote.remote_connection import RemoteConnection from appium.common.helper import library_version @@ -24,5 +26,8 @@ def get_remote_connection_headers(cls, parsed_url, keep_alive=True): """Override get_remote_connection_headers in RemoteConnection""" headers = RemoteConnection.get_remote_connection_headers(parsed_url, keep_alive=keep_alive) headers['User-Agent'] = 'appium/python {} ({})'.format(library_version(), headers['User-Agent']) + if parsed_url.path.endswith('/session'): + # https://github.com/appium/appium-base-driver/pull/400 + headers['X-Idempotency-Key'] = str(uuid.uuid4()) return headers