Skip to content

Commit c2006ee

Browse files
committed
Support 'no-cookie-jar' setting to disable cookieJar for given request
1 parent b830746 commit c2006ee

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ Name | Syntax | Description
686686
-----|-----------|--------------------------------------------------------------
687687
note | `# @note` | Use for request confirmation, especially for critical request
688688
no-redirect | `# @no-redirect` | Don't follow the 3XX response as redirects
689+
no-cookie-jar | `# @no-cookie-jar` | Don't save cookies in the cookie jar
689690

690691
> All the above leading `#` can be replaced with `//`
691692

src/models/configurationSettings.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,21 @@ export class RequestSettings implements Partial<IRestClientSettings> {
304304

305305
private _followRedirect?: boolean = undefined;
306306

307+
private _rememberCookiesForSubsequentRequests?: boolean = undefined;
308+
307309
public get followRedirect() {
308310
return this._followRedirect;
309311
}
310312

313+
public get rememberCookiesForSubsequentRequests() {
314+
return this._rememberCookiesForSubsequentRequests;
315+
}
316+
311317
public constructor(metadatas: Map<RequestMetadata, string | undefined>) {
312318
if (metadatas.has(RequestMetadata.NoRedirect)) {
313319
this._followRedirect = false;
320+
} else if (metadatas.has(RequestMetadata.NoCookieJar)) {
321+
this._rememberCookiesForSubsequentRequests = false;
314322
}
315323
}
316324
}
@@ -346,7 +354,7 @@ export class RestClientSettings implements IRestClientSettings {
346354
}
347355

348356
public get rememberCookiesForSubsequentRequests() {
349-
return this.systemSettings.rememberCookiesForSubsequentRequests;
357+
return this.requestSettings.rememberCookiesForSubsequentRequests ?? this.systemSettings.rememberCookiesForSubsequentRequests;
350358
}
351359

352360
public get enableTelemetry() {

src/models/requestMetadata.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export enum RequestMetadata {
1111
* Represents don't follow the 3XX response as redirects
1212
*/
1313
NoRedirect = 'no-redirect',
14+
15+
/**
16+
* Represents the cookie jar is disabled for this request
17+
*/
18+
NoCookieJar = 'no-cookie-jar',
1419
}
1520

1621
export function fromString(value: string): RequestMetadata | undefined {

0 commit comments

Comments
 (0)