Skip to content

Commit e19d7b5

Browse files
committed
fix: prevent error with undefined/null headers entries
1 parent b011a6c commit e19d7b5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/https/request.android.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,11 @@ export function createRequest(opts: HttpsRequestOptions, useLegacy: boolean = tr
472472
request.url(opts.url);
473473

474474
if (opts.headers) {
475-
Object.keys(opts.headers).forEach((key) => request.addHeader(key, opts.headers[key] as any));
475+
Object.keys(opts.headers).forEach((key) => {
476+
if (opts.headers[key]) {
477+
request.addHeader(key, opts.headers[key] as any);
478+
}
479+
});
476480
}
477481

478482
if (opts.cachePolicy) {

src/https/request.ios.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ export function createRequest(opts: HttpsRequestOptions, useLegacy: boolean = tr
370370
if (heads) {
371371
headers = NSMutableDictionary.dictionary();
372372
Object.keys(heads).forEach(
373-
(key) => headers.setValueForKey(heads[key], key)
373+
(key) => {
374+
if (heads[key]) {
375+
headers.setValueForKey(heads[key], key);
376+
}
377+
}
374378
// manager.requestSerializer.setValueForHTTPHeaderField(
375379
// heads[key] as any,
376380
// key

0 commit comments

Comments
 (0)