Skip to content

Latest commit

 

History

History
342 lines (151 loc) · 7.21 KB

tough-cookie.memorycookiestore.md

File metadata and controls

342 lines (151 loc) · 7.21 KB

Home > tough-cookie > MemoryCookieStore

MemoryCookieStore class

An in-memory Store implementation for CookieJar. This is the default implementation used by CookieJar and supports both async and sync operations. Also supports serialization, getAllCookies, and removeAllCookies.

Signature:

export declare class MemoryCookieStore extends Store 

Extends: Store

Constructors

Constructor

Modifiers

Description

(constructor)()

Create a new MemoryCookieStore.

Properties

Property

Modifiers

Type

Description

synchronous

boolean

This value is true since MemoryCookieStore implements synchronous functionality.

Methods

Method

Modifiers

Description

findCookie(domain, path, key)

Retrieve a Cookie with the given domain, path, and key (name). The RFC maintains that exactly one of these cookies should exist in a store. If the store is using versioning, this means that the latest or newest such cookie should be returned.

findCookie(domain, path, key, callback)

Retrieve a Cookie with the given domain, path, and key (name). The RFC maintains that exactly one of these cookies should exist in a store. If the store is using versioning, this means that the latest or newest such cookie should be returned.

Callback takes an error and the resulting Cookie object. If no cookie is found then null MUST be passed instead (that is, not an error).

findCookies(domain, path, allowSpecialUseDomain)

Locates all Cookie values matching the given domain and path.

The resulting list is checked for applicability to the current request according to the RFC (domain-match, path-match, http-only-flag, secure-flag, expiry, and so on), so it's OK to use an optimistic search algorithm when implementing this method. However, the search algorithm used SHOULD try to find cookies that domainMatch() the domain and pathMatch() the path in order to limit the amount of checking that needs to be done.

findCookies(domain, path, allowSpecialUseDomain, callback)

Locates all Cookie values matching the given domain and path.

The resulting list is checked for applicability to the current request according to the RFC (domain-match, path-match, http-only-flag, secure-flag, expiry, and so on), so it's OK to use an optimistic search algorithm when implementing this method. However, the search algorithm used SHOULD try to find cookies that domainMatch() the domain and pathMatch() the path in order to limit the amount of checking that needs to be done.

getAllCookies()

Gets all the cookies in the store.

getAllCookies(callback)

Gets all the cookies in the store.

putCookie(cookie)

Adds a new Cookie to the store. The implementation SHOULD replace any existing cookie with the same domain, path, and key properties.

putCookie(cookie, callback)

Adds a new Cookie to the store. The implementation SHOULD replace any existing cookie with the same domain, path, and key properties.

removeAllCookies()

Removes all cookies from the store.

removeAllCookies(callback)

Removes all cookies from the store.

removeCookie(domain, path, key)

Remove a cookie from the store (see notes on findCookie about the uniqueness constraint).

removeCookie(domain, path, key, callback)

Remove a cookie from the store (see notes on findCookie about the uniqueness constraint).

removeCookies(domain, path)

Removes matching cookies from the store. The path parameter is optional and if missing, means all paths in a domain should be removed.

removeCookies(domain, path, callback)

Removes matching cookies from the store. The path parameter is optional and if missing, means all paths in a domain should be removed.

updateCookie(oldCookie, newCookie)

Update an existing Cookie. The implementation MUST update the value for a cookie with the same domain, path, and key. The implementation SHOULD check that the old value in the store is equivalent to oldCookie - how the conflict is resolved is up to the store.

updateCookie(oldCookie, newCookie, callback)

Update an existing Cookie. The implementation MUST update the value for a cookie with the same domain, path, and key. The implementation SHOULD check that the old value in the store is equivalent to oldCookie - how the conflict is resolved is up to the store.