From 47a8aa62a9ed7058500a4779d6299bca491da593 Mon Sep 17 00:00:00 2001 From: Muvaffak Onus Date: Wed, 22 Apr 2026 21:21:31 -0700 Subject: [PATCH] feat(client): add ability to set headers on requests Signed-off-by: Muvaffak Onus --- lib/types.ts | 4 ++++ lib/webdriveragent.ts | 3 +++ package.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/types.ts b/lib/types.ts index 4a724161d..e748c3bd5 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,3 +1,5 @@ +import {type HTTPHeaders} from '@appium/types'; + // WebDriverAgentLib/Utilities/FBSettings.h export interface WDASettings { elementResponseAttribute?: string; @@ -92,6 +94,7 @@ export interface WebDriverAgentArgs { resultBundleVersion?: string; reqBasePath?: string; launchTimeout?: number; + extraRequestHeaders?: HTTPHeaders; } export interface AppleDevice { @@ -138,4 +141,5 @@ export interface XcodeBuildArgs { allowProvisioningDeviceRegistration?: boolean; resultBundlePath?: string; resultBundleVersion?: string; + extraRequestHeaders?: HTTPHeaders; } diff --git a/lib/webdriveragent.ts b/lib/webdriveragent.ts index 95daacf4b..69c8fc52d 100644 --- a/lib/webdriveragent.ts +++ b/lib/webdriveragent.ts @@ -346,6 +346,7 @@ export class WebDriverAgent { timeout: this.wdaConnectionTimeout, keepAlive: true, scheme: this.url.protocol ? this.url.protocol.replace(':', '') : 'http', + headers: this.args.extraRequestHeaders, }; if (this.args.reqBasePath) { proxyOpts.reqBasePath = this.args.reqBasePath; @@ -560,10 +561,12 @@ export class WebDriverAgent { */ private async getStatus(timeoutMs: number = 0): Promise { const noSessionProxy = new NoSessionProxy({ + scheme: this.url.protocol ? this.url.protocol.replace(':', '') : 'http', server: this.url.hostname ?? undefined, port: parseInt(this.url.port ?? '', 10) || undefined, base: this.basePath, timeout: 3000, + headers: this.args.extraRequestHeaders, }); const sendGetStatus = async () => diff --git a/package.json b/package.json index 56d40e999..eec8ecb0b 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "typescript": "^6.0.2" }, "dependencies": { - "@appium/base-driver": "^10.0.0-rc.1", + "@appium/base-driver": "^10.3.0", "@appium/strongbox": "^1.0.0-rc.1", "@appium/support": "^7.0.0-rc.1", "appium-ios-device": "^3.0.0",