Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/modules/datafile-manager/datafileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface DatafileManagerConfig {
updateInterval?: number;
urlTemplate?: string;
cache?: PersistentKeyValueCache;
customHeaders?: Record<string, string>;
}

export interface NodeDatafileManagerConfig extends DatafileManagerConfig {
Expand Down
9 changes: 9 additions & 0 deletions lib/modules/datafile-manager/httpPollingDatafileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export default abstract class HttpPollingDatafileManager implements DatafileMana

private sdkKey: string;

private customHeaders?: Record<string, string>;

// When true, this means the update interval timeout fired before the current
// sync completed. In that case, we should sync again immediately upon
// completion of the current request, instead of waiting another update
Expand All @@ -114,11 +116,13 @@ export default abstract class HttpPollingDatafileManager implements DatafileMana
updateInterval = DEFAULT_UPDATE_INTERVAL,
urlTemplate = DEFAULT_URL_TEMPLATE,
cache = noOpKeyValueCache,
customHeaders,
} = configWithDefaultsApplied;

this.cache = cache;
this.cacheKey = 'opt-datafile-' + sdkKey;
this.sdkKey = sdkKey;
this.customHeaders = customHeaders;
this.isReadyPromiseSettled = false;
this.readyPromiseResolver = (): void => { };
this.readyPromiseRejecter = (): void => { };
Expand Down Expand Up @@ -266,6 +270,11 @@ export default abstract class HttpPollingDatafileManager implements DatafileMana

private syncDatafile(): void {
const headers: Headers = {};

if (this.customHeaders) {
Object.assign(headers, this.customHeaders);
}

if (this.lastResponseLastModified) {
headers['if-modified-since'] = this.lastResponseLastModified;
}
Expand Down
1 change: 1 addition & 0 deletions lib/shared_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface DatafileOptions {
updateInterval?: number;
urlTemplate?: string;
datafileAccessToken?: string;
customHeaders?: Record<string, string>;
}

export interface OdpOptions {
Expand Down
Loading