Skip to content

Commit d6519fe

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

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { type HTTPHeaders } from '@appium/types';
2+
13
// WebDriverAgentLib/Utilities/FBSettings.h
24
export interface WDASettings {
35
elementResponseAttribute?: string;
@@ -92,6 +94,7 @@ export interface WebDriverAgentArgs {
9294
resultBundleVersion?: string;
9395
reqBasePath?: string;
9496
launchTimeout?: number;
97+
extraRequestHeaders?: HTTPHeaders;
9598
}
9699

97100
export interface AppleDevice {
@@ -138,4 +141,5 @@ export interface XcodeBuildArgs {
138141
allowProvisioningDeviceRegistration?: boolean;
139142
resultBundlePath?: string;
140143
resultBundleVersion?: string;
144+
extraRequestHeaders?: HTTPHeaders;
141145
}

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.extraRequestHeaders,
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.extraRequestHeaders,
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)