unprint 0.18.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/app.js +17 -7
- package/tests/init.js +1 -0
package/package.json
CHANGED
package/src/app.js
CHANGED
|
@@ -1056,6 +1056,14 @@ function getCookie(options) {
|
|
|
1056
1056
|
return headerCookieData;
|
|
1057
1057
|
}
|
|
1058
1058
|
|
|
1059
|
+
function filterHeaders(headers, options) {
|
|
1060
|
+
if (headers && options.defaultHeaders !== false) {
|
|
1061
|
+
return Object.fromEntries(Object.entries(headers).filter(([_key, value]) => value !== null));
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
return headers;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1059
1067
|
function curateResponse(res, data, options, { url, control, customOptions }) {
|
|
1060
1068
|
const base = {
|
|
1061
1069
|
ok: true,
|
|
@@ -1238,11 +1246,11 @@ async function browserRequest(url, customOptions = {}) {
|
|
|
1238
1246
|
const headers = route.request().headers();
|
|
1239
1247
|
|
|
1240
1248
|
route.continue({
|
|
1241
|
-
headers: {
|
|
1249
|
+
headers: filterHeaders({
|
|
1242
1250
|
...headers,
|
|
1243
1251
|
...options.headers,
|
|
1244
1252
|
cookie: getCookie(options),
|
|
1245
|
-
},
|
|
1253
|
+
}, options),
|
|
1246
1254
|
});
|
|
1247
1255
|
});
|
|
1248
1256
|
|
|
@@ -1393,15 +1401,17 @@ async function request(url, body, customOptions = {}, method = 'GET') {
|
|
|
1393
1401
|
const curatedBody = curateRequestBody(body);
|
|
1394
1402
|
const curatedCookie = getCookie(options);
|
|
1395
1403
|
|
|
1404
|
+
const headers = filterHeaders({
|
|
1405
|
+
...curatedBody.headers,
|
|
1406
|
+
...options.headers,
|
|
1407
|
+
cookie: curatedCookie,
|
|
1408
|
+
}, options);
|
|
1409
|
+
|
|
1396
1410
|
const res = await limiter.schedule(async () => undici.fetch(url, {
|
|
1397
1411
|
dispatcher: agent,
|
|
1398
1412
|
method,
|
|
1399
1413
|
body: curatedBody.body,
|
|
1400
|
-
headers
|
|
1401
|
-
...curatedBody.headers,
|
|
1402
|
-
...options.headers,
|
|
1403
|
-
cookie: curatedCookie,
|
|
1404
|
-
},
|
|
1414
|
+
headers,
|
|
1405
1415
|
signal: options.abortSignal,
|
|
1406
1416
|
})).catch((error) => ({ // tends to happen when proxy can't reach host
|
|
1407
1417
|
status: 500,
|