Skip to content

Commit fe0ba24

Browse files
committed
feat: add disableCookies in requester options
1 parent 570c992 commit fe0ba24

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

CHANGELOG.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
unreleased:
2+
new features:
3+
- GH-1533 Add support for disabling cookie jar via requester options
4+
15
7.49.0:
26
date: 2025-10-16
37
new features:

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ runner.run(collection, {
8585
// jar.allowProgrammaticAccess = function (domain) { return domain === 'postman-echo.com'; };
8686
cookieJar: jar,
8787

88+
// Prevents cookie jar from being used for in a request
89+
disableCookies: false,
90+
8891
// Controls redirect behavior (only supported on Node, ignored in the browser)
8992
followRedirects: true,
9093

docs/protocol-profile-behavior.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Follow HTTP 3xx responses as redirects.
1515
- `maxRedirects: Number`<br/>
1616
Set maximum number of redirects to follow.
1717

18+
- `disableCookies: Boolean`<br/>
19+
Prevent cookie jar from being used in a request.
20+
1821
- `disableBodyPruning: Boolean`<br/>
1922
Control request body pruning for following methods: ```GET, COPY, HEAD, PURGE, UNLOCK```
2023

lib/requester/core.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ var dns = require('dns'),
8585
removeRefererHeader: 'removeRefererHeaderOnRedirect',
8686

8787
// Select the HTTP protocol version to be used. Valid options are http1/http2/auto
88-
protocolVersion: 'protocolVersion'
88+
protocolVersion: 'protocolVersion',
89+
90+
// disable cookie jar
91+
disableCookies: 'disableCookies'
8992
},
9093

9194
/**
@@ -433,7 +436,6 @@ module.exports = {
433436
reqOption,
434437
portNumber,
435438
behaviorName,
436-
disableCookies,
437439
port = url && url.port,
438440
hostname = url && url.hostname && url.hostname.toLowerCase(),
439441
proxyHostname = request.proxy && request.proxy.host;
@@ -484,13 +486,8 @@ module.exports = {
484486
options[reqOption] = resolveWithProtocolProfileBehavior(behaviorName, defaultOpts, protocolProfileBehavior);
485487
}
486488

487-
// set cookie jar if not disabled
488-
// check per-request override first, then fall back to requester-level setting
489-
disableCookies = protocolProfileBehavior.disableCookies !== undefined ?
490-
protocolProfileBehavior.disableCookies :
491-
defaultOpts.disableCookies;
492489

493-
if (!disableCookies) {
490+
if (!options.disableCookies) {
494491
options.jar = defaultOpts.cookieJar || true;
495492
}
496493

lib/requester/dry-run.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,13 @@ function dryRun (request, options, done) {
315315
var cookieJar = options.cookieJar,
316316
implicitCacheControl = options.implicitCacheControl,
317317
implicitTraceHeader = options.implicitTraceHeader,
318-
disabledSystemHeaders = _.get(options.protocolProfileBehavior, 'disabledSystemHeaders') || {},
319-
disableCookies = _.get(options.protocolProfileBehavior, 'disableCookies');
318+
protocolProfileBehavior = options.protocolProfileBehavior,
319+
disabledSystemHeaders = _.get(protocolProfileBehavior, 'disabledSystemHeaders') || {},
320320

321-
// if protocolProfileBehavior.disableCookies is undefined, fall back to requester option
322-
if (disableCookies === undefined) {
323-
disableCookies = _.get(options, 'disableCookies', false);
324-
}
321+
// TODO: Unify the logic to read ppb properties with core.js
322+
disableCookies = Object.hasOwn(protocolProfileBehavior || {}, 'disableCookies') ?
323+
protocolProfileBehavior.disableCookies :
324+
options?.disableCookies;
325325

326326
async.waterfall([
327327
function setContentTypeHeader (next) {

0 commit comments

Comments
 (0)