@gatling.io/http
Version: 
Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
67 lines (66 loc) • 3.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CookieKey = exports.Cookie = exports.flushHttpCache = exports.flushCookieJar = exports.flushSessionCookies = exports.getCookieValue = exports.addCookie = void 0;
const core_1 = require("@gatling.io/core");
const jvm_types_1 = require("@gatling.io/jvm-types");
const wrapAddCookie = (_underlying) => ({
    _underlying,
    withDomain: (domain) => wrapAddCookie(_underlying.withDomain(domain)),
    withPath: (path) => wrapAddCookie(_underlying.withPath(path)),
    withMaxAge: (maxAge) => wrapAddCookie(_underlying.withMaxAge(maxAge)),
    withSecure: (secure) => wrapAddCookie(_underlying.withSecure(secure))
});
const wrapGetCookie = (_underlying) => ({
    _underlying,
    withDomain: (domain) => wrapGetCookie(typeof domain === "function" ? _underlying.withDomain((0, core_1.underlyingSessionTo)(domain)) : _underlying.withPath(domain)),
    withPath: (path) => wrapGetCookie(_underlying.withPath(path)),
    withSecure: (secure) => wrapGetCookie(_underlying.withSecure(secure)),
    saveAs: (saveAs) => wrapGetCookie(_underlying.saveAs(saveAs))
});
/**
 * Create an action to add a Cookie
 *
 * @param cookie - the DSL for adding a cookie
 * @returns an ActionBuilder
 */
const addCookie = (cookie) => (0, core_1.wrapActionBuilder)(jvm_types_1.HttpDsl.addCookie(cookie._underlying));
exports.addCookie = addCookie;
/**
 * Create an action to get a Cookie value into the Session
 *
 * @param cookie - the DSL for getting a cookie
 * @returns an ActionBuilder
 */
const getCookieValue = (cookie) => (0, core_1.wrapActionBuilder)(jvm_types_1.HttpDsl.getCookieValue(cookie._underlying));
exports.getCookieValue = getCookieValue;
/**
 * Create an action to flush the Session (non-persistent) Cookies of the user
 *
 * @returns an ActionBuilder
 */
const flushSessionCookies = () => (0, core_1.wrapActionBuilder)(jvm_types_1.HttpDsl.flushSessionCookies());
exports.flushSessionCookies = flushSessionCookies;
/**
 * Create an action to flush all the Cookies of the user
 *
 * @returns an ActionBuilder
 */
const flushCookieJar = () => (0, core_1.wrapActionBuilder)(jvm_types_1.HttpDsl.flushCookieJar());
exports.flushCookieJar = flushCookieJar;
/**
 * Create an action to flush the HTTP cache of the user
 *
 * @returns an ActionBuilder
 */
const flushHttpCache = () => (0, core_1.wrapActionBuilder)(jvm_types_1.HttpDsl.flushHttpCache());
exports.flushHttpCache = flushHttpCache;
const Cookie = (name, value) => wrapAddCookie(typeof name === "function"
    ? typeof value === "function"
        ? jvm_types_1.HttpDsl.Cookie((0, core_1.underlyingSessionTo)(name), (0, core_1.underlyingSessionTo)(value))
        : jvm_types_1.HttpDsl.Cookie((0, core_1.underlyingSessionTo)(name), value)
    : typeof value === "function"
        ? jvm_types_1.HttpDsl.Cookie(name, (0, core_1.underlyingSessionTo)(value))
        : jvm_types_1.HttpDsl.Cookie(name, value));
exports.Cookie = Cookie;
const CookieKey = (name) => wrapGetCookie(typeof name === "function" ? jvm_types_1.HttpDsl.CookieKey((0, core_1.underlyingSessionTo)(name)) : jvm_types_1.HttpDsl.CookieKey(name));
exports.CookieKey = CookieKey;