Skip to content

Commit 6f73492

Browse files
[FSSDK-11938] custom header
1 parent 7e89e43 commit 6f73492

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

lib/modules/datafile-manager/datafileManager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface DatafileManagerConfig {
4444
updateInterval?: number;
4545
urlTemplate?: string;
4646
cache?: PersistentKeyValueCache;
47+
customHeaders?: Record<string, string>;
4748
}
4849

4950
export interface NodeDatafileManagerConfig extends DatafileManagerConfig {

lib/modules/datafile-manager/httpPollingDatafileManager.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ export default abstract class HttpPollingDatafileManager implements DatafileMana
9696

9797
private sdkKey: string;
9898

99+
private customHeaders?: Record<string, string>;
100+
99101
// When true, this means the update interval timeout fired before the current
100102
// sync completed. In that case, we should sync again immediately upon
101103
// completion of the current request, instead of waiting another update
@@ -114,11 +116,13 @@ export default abstract class HttpPollingDatafileManager implements DatafileMana
114116
updateInterval = DEFAULT_UPDATE_INTERVAL,
115117
urlTemplate = DEFAULT_URL_TEMPLATE,
116118
cache = noOpKeyValueCache,
119+
customHeaders,
117120
} = configWithDefaultsApplied;
118121

119122
this.cache = cache;
120123
this.cacheKey = 'opt-datafile-' + sdkKey;
121124
this.sdkKey = sdkKey;
125+
this.customHeaders = customHeaders;
122126
this.isReadyPromiseSettled = false;
123127
this.readyPromiseResolver = (): void => { };
124128
this.readyPromiseRejecter = (): void => { };
@@ -266,6 +270,11 @@ export default abstract class HttpPollingDatafileManager implements DatafileMana
266270

267271
private syncDatafile(): void {
268272
const headers: Headers = {};
273+
274+
if (this.customHeaders) {
275+
Object.assign(headers, this.customHeaders);
276+
}
277+
269278
if (this.lastResponseLastModified) {
270279
headers['if-modified-since'] = this.lastResponseLastModified;
271280
}

lib/shared_types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export interface DatafileOptions {
9595
updateInterval?: number;
9696
urlTemplate?: string;
9797
datafileAccessToken?: string;
98+
customHeaders?: Record<string, string>;
9899
}
99100

100101
export interface OdpOptions {

0 commit comments

Comments
 (0)