Skip to content

Commit 33015d8

Browse files
committed
feat(client): add ability to set headers on requests
Signed-off-by: Muvaffak Onus <me@muvaf.com>
1 parent 2ca4503 commit 33015d8

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

lib/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface WebDriverAgentArgs {
9292
resultBundleVersion?: string;
9393
reqBasePath?: string;
9494
launchTimeout?: number;
95+
wdaRequestHeaders?: Record<string, string>;
9596
}
9697

9798
export interface AppleDevice {
@@ -138,4 +139,5 @@ export interface XcodeBuildArgs {
138139
allowProvisioningDeviceRegistration?: boolean;
139140
resultBundlePath?: string;
140141
resultBundleVersion?: string;
142+
wdaRequestHeaders?: Record<string, string>;
141143
}

lib/webdriveragent.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ export class WebDriverAgent {
346346
timeout: this.wdaConnectionTimeout,
347347
keepAlive: true,
348348
scheme: this.url.protocol ? this.url.protocol.replace(':', '') : 'http',
349+
headers: this.args.wdaRequestHeaders,
349350
};
350351
if (this.args.reqBasePath) {
351352
proxyOpts.reqBasePath = this.args.reqBasePath;
@@ -560,10 +561,12 @@ export class WebDriverAgent {
560561
*/
561562
private async getStatus(timeoutMs: number = 0): Promise<StringRecord | null> {
562563
const noSessionProxy = new NoSessionProxy({
564+
scheme: this.url.protocol ? this.url.protocol.replace(':', '') : 'http',
563565
server: this.url.hostname ?? undefined,
564566
port: parseInt(this.url.port ?? '', 10) || undefined,
565567
base: this.basePath,
566568
timeout: 3000,
569+
headers: this.args.wdaRequestHeaders,
567570
});
568571

569572
const sendGetStatus = async () =>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"typescript": "^6.0.2"
7373
},
7474
"dependencies": {
75-
"@appium/base-driver": "^10.0.0-rc.1",
75+
"@appium/base-driver": "^10.3.0",
7676
"@appium/strongbox": "^1.0.0-rc.1",
7777
"@appium/support": "^7.0.0-rc.1",
7878
"appium-ios-device": "^3.0.0",

0 commit comments

Comments
 (0)