@gatling.io/http
Version:
Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
524 lines (523 loc) • 20.7 kB
TypeScript
import { ActionBuilder, Body, CheckBuilder, Condition, Duration, Session } from "@gatling.io/core";
import { BodyPart } from "../bodyPart";
import { Proxy } from "../proxy";
import JvmRequestActionBuilder = io.gatling.javaapi.http.RequestActionBuilder;
import JvmRequestWithBodyActionBuilder = io.gatling.javaapi.http.RequestWithBodyActionBuilder;
import JvmHttpRequestActionBuilder = io.gatling.javaapi.http.HttpRequestActionBuilder;
export * from "./body";
export * from "./request";
export interface RequestActionBuilder<T> {
/**
* Set some query parameter
*
* @param name - the name of the parameter, expressed as a Gatling Expression Language String
* @param value - the value of the parameter, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
queryParam(name: string, value: string): T;
/**
* Set some query parameter
*
* @param name - the name of the parameter, expressed as a Gatling Expression Language String
* @param value - the static value of the parameter
* @returns a new DSL instance
*/
queryParam(name: string, value: any): T;
/**
* Set some query parameter
*
* @param name - the name of the parameter, expressed as a Gatling Expression Language String
* @param value - the value of the parameter, expressed as a function
* @returns a new DSL instance
*/
queryParam(name: string, value: (session: Session) => any): T;
/**
* Set some query parameter
*
* @param name - the name of the parameter, expressed as a function
* @param value - the value of the parameter, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
queryParam(name: (session: Session) => string, value: string): T;
/**
* Set some query parameter
*
* @param name - the name of the parameter, expressed as a function
* @param value - the static value of the parameter
* @returns a new DSL instance
*/
queryParam(name: (session: Session) => string, value: any): T;
/**
* Set some query parameter
*
* @param name - the name of the parameter, expressed as a function
* @param value - the value of the parameter, expressed as a function
* @returns a new DSL instance
*/
queryParam(name: (session: Session) => string, value: (session: Session) => any): T;
/**
* Set a multivalued query parameter
*
* @param name - the name of the parameter, expressed as a Gatling Expression Language String
* @param values - the list of values of the parameter, expressed as a Gatling Expression Language
* String
* @returns a new DSL instance
*/
multivaluedQueryParam(name: string, values: string): T;
/**
* Set a multivalued query parameter
*
* @param name - the name of the parameter, expressed as a Gatling Expression Language String
* @param values - the static list of values of the parameter
* @returns a new DSL instance
*/
multivaluedQueryParam(name: string, values: any[]): T;
/**
* Set a multivalued query parameter
*
* @param name - the name of the parameter, expressed as a Gatling Expression Language String
* @param values - the list of values of the parameter, expressed as a function
* @returns a new DSL instance
*/
multivaluedQueryParam(name: string, values: (session: Session) => any[]): T;
/**
* Set a multivalued query parameter
*
* @param name - the name of the parameter, expressed as a function
* @param values - the list of values of the parameter, expressed as a Gatling Expression Language
* String
* @returns a new DSL instance
*/
multivaluedQueryParam(name: (session: Session) => string, values: string): T;
/**
* Set a multivalued query parameter
*
* @param name - the name of the parameter, expressed as a function
* @param values - the static list of values of the parameter
* @returns a new DSL instance
*/
multivaluedQueryParam(name: (session: Session) => string, values: any[]): T;
/**
* Set a multivalued query parameter
*
* @param name - the name of the parameter, expressed as a function
* @param values - the list of values of the parameter, expressed as a function
* @returns a new DSL instance
*/
multivaluedQueryParam(name: (session: Session) => string, values: (session: Session) => any[]): T;
/**
* Set multiple query params
*
* @param map - a static Map of query params
* @returns a new DSL instance
*/
queryParamMap(map: string): T;
/**
* Set multiple query params
*
* @param map - a Map of query params, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
queryParamMap(map: Record<string, any>): T;
/**
* Set multiple query params
*
* @param map - a Map of query params, expressed as a function
* @returns a new DSL instance
*/
queryParamMap(map: (session: Session) => Record<string, any>): T;
/**
* Set a header
*
* @param name - the static header name
* @param value - the header value, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
header(name: string, value: string): T;
/**
* Set a header
*
* @param name - the static header name
* @param value - the header value, expressed as a function
* @returns a new DSL instance
*/
header(name: string, value: (session: Session) => string): T;
/**
* Set multiple headers
*
* @param headers - the headers, names are static but values are expressed as a Gatling Expression
* Language String
* @returns a new DSL instance
*/
headers(headers: Record<string, string>): T;
/**
* Ignore common headers set in the Http protocol configuration
*
* @returns a new DSL instance
*/
ignoreProtocolHeaders(): T;
/**
* Set the authorization header for Basic Auth
*
* @param username - the username, expressed as a Gatling Expression Language String
* @param password - the password, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
basicAuth(username: string, password: string): T;
/**
* Set the authorization header for Basic Auth
*
* @param username - the username, expressed as a Gatling Expression Language String
* @param password - the password, expressed as a function
* @returns a new DSL instance
*/
basicAuth(username: string, password: (session: Session) => string): T;
/**
* Set the authorization header for Basic Auth
*
* @param username - the username, expressed as a function
* @param password - the password, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
basicAuth(username: (session: Session) => string, password: string): T;
/**
* Set the authorization header for Basic Auth
*
* @param username - the username, expressed as a function
* @param password - the password, expressed as a function
* @returns a new DSL instance
*/
basicAuth(username: (session: Session) => string, password: (session: Session) => string): T;
/**
* Set the authorization header for Digest Auth
*
* @param username - the username, expressed as a Gatling Expression Language String
* @param password - the password, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
digestAuth(username: string, password: string): T;
/**
* Set the authorization header for Digest Auth
*
* @param username - the username, expressed as a Gatling Expression Language String
* @param password - the password, expressed as a function
* @returns a new DSL instance
*/
digestAuth(username: string, password: (session: Session) => string): T;
/**
* Set the authorization header for Digest Auth
*
* @param username - the username, expressed as a function
* @param password - the password, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
digestAuth(username: (session: Session) => string, password: string): T;
/**
* Set the authorization header for Digest Auth
*
* @param username - the username, expressed as a function
* @param password - the password, expressed as a function
* @returns a new DSL instance
*/
digestAuth(username: (session: Session) => string, password: (session: Session) => string): T;
/**
* Disable the automatic url encoding that tries to detect unescaped reserved chars
*
* @returns a new DSL instance
*/
disableUrlEncoding(): T;
/**
* Define a Proxy to be used for this request
*
* @param proxy - the proxy
* @returns a new DSL instance
*/
proxy(proxy: Proxy): T;
/**
* Instruct sign the request with OAuth1 before writing it on the wire
*
* @param consumerKey - the consumerKey, expressed as a Gatling Expression Language String
* @param clientSharedSecret - the clientSharedSecret, expressed as a Gatling Expression Language
* String
* @param token - the token, expressed as a Gatling Expression Language String
* @param tokenSecret - the tokenSecret, expressed as a Gatling Expression Language String
* @returns a new DSL instance
*/
signWithOAuth1(consumerKey: string, clientSharedSecret: string, token: string, tokenSecret: string): T;
/**
* Instruct sign the request with OAuth1 before writing it on the wire
*
* @param consumerKey - the consumerKey, expressed as a function
* @param clientSharedSecret - the clientSharedSecret, expressed as a function
* @param token - the token, expressed as a function
* @param tokenSecret - the tokenSecret, expressed as a function
* @returns a new DSL instance
*/
signWithOAuth1(consumerKey: (session: Session) => string, clientSharedSecret: (session: Session) => string, token: (session: Session) => string, tokenSecret: (session: Session) => string): T;
}
export declare const requestActionBuilderImpl: <T, J extends JvmRequestActionBuilder<J, any>>(jvmBuilder: J, wrap: (_underlying: J) => T) => RequestActionBuilder<T>;
export interface RequestWithBodyActionBuilder<T> {
/**
* Define a request body
*
* @param body - the request body
* @returns a new HttpRequestActionBuilder instance
*/
body(body: Body): T;
/**
* Set a multipart body part
*
* @param part - the part
* @returns a new HttpRequestActionBuilder instance
*/
bodyPart(part: BodyPart): T;
/**
* Set multiple multipart body parts
*
* @param parts - the parts
* @returns a new HttpRequestActionBuilder instance
*/
bodyParts(...parts: BodyPart[]): T;
/**
* Set the content-type header for multipart body.
*
* @returns a new HttpRequestActionBuilder instance
*/
asMultipartForm(): T;
/**
* Set the content-type header for form-urlencoding body.
*
* @returns a new HttpRequestActionBuilder instance
*/
asFormUrlEncoded(): T;
/**
* Set an HTML form parameter
*
* @param key - the parameter key, expressed as a Gatling Expression Language String
* @param value - the parameter value, expressed as a Gatling Expression Language String
* @returns a new HttpRequestActionBuilder instance
*/
formParam(key: string, value: string): T;
/**
* Set an HTML form parameter
*
* @param key - the parameter key, expressed as a Gatling Expression Language String
* @param value - the parameter static value
* @returns a new HttpRequestActionBuilder instance
*/
formParam(key: string, value: any): T;
/**
* Set an HTML form parameter
*
* @param key - the parameter key, expressed as a Gatling Expression Language String
* @param value - the parameter value, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
formParam(key: string, value: (session: Session) => any): T;
/**
* Set an HTML form parameter
*
* @param key - the parameter key, expressed as a function
* @param value - the parameter value, expressed as a Gatling Expression Language String
* @returns a new HttpRequestActionBuilder instance
*/
formParam(key: (session: Session) => string, value: string): T;
/**
* Set an HTML form parameter
*
* @param key - the parameter key, expressed as a function
* @param value - the parameter static value
* @returns a new HttpRequestActionBuilder instance
*/
formParam(key: (session: Session) => string, value: any): T;
/**
* Set an HTML form parameter
*
* @param key - the parameter key, expressed as a function
* @param value - the parameter value, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
formParam(key: (session: Session) => string, value: (session: Session) => any): T;
/**
* Set an HTML form multivalued parameter
*
* @param key - the parameter key, expressed as a Gatling Expression Language String
* @param values - the parameter values, as a Gatling EL string
* @returns a new HttpRequestActionBuilder instance
*/
multivaluedFormParam(key: string, values: string): T;
/**
* Set an HTML form multivalued parameter
*
* @param key - the parameter key, expressed as a Gatling Expression Language String
* @param values - the static parameter values
* @returns a new HttpRequestActionBuilder instance
*/
multivaluedFormParam(key: string, values: any[]): T;
/**
* Set an HTML form multivalued parameter
*
* @param key - the parameter key, expressed as a Gatling Expression Language String
* @param values - the parameter values, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
multivaluedFormParam(key: string, values: (session: Session) => any[]): T;
/**
* Set an HTML form multivalued parameter
*
* @param key - the parameter key, expressed as a function
* @param values - the static parameter values
* @returns a new HttpRequestActionBuilder instance
*/
multivaluedFormParam(key: (session: Session) => string, values: any[]): T;
/**
* Set an HTML form multivalued parameter
*
* @param key - the parameter key, expressed as a function
* @param values - the parameter values, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
multivaluedFormParam(key: (session: Session) => string, values: (session: Session) => any[]): T;
/**
* Set multiple form parameters
*
* @param map - the static parameters
* @returns a new HttpRequestActionBuilder instance
*/
formParamMap(map: Record<string, any>): T;
/**
* Set multiple form parameters
*
* @param map - the parameters, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
formParamMap(map: (session: Session) => Record<string, any>): T;
/**
* Set a form, typically captured from a form check
*
* @param form - the form inputs, expressed as a Gatling Expression Language String
* @returns a new HttpRequestActionBuilder instance
*/
form(form: string): T;
/**
* Set a form, typically captured from a form check
*
* @param map - the form inputs, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
form(map: (session: Session) => Record<string, any>): T;
/**
* Set a form file upload
*
* @param name - the name of the file part, expressed as a Gatling Expression Language String
* @param filePath - the path of the file, either relative to the root of the classpath, or
* absolute, expressed as a Gatling Expression Language String
* @returns a new HttpRequestActionBuilder instance
*/
formUpload(name: string, filePath: string): T;
/**
* Set a form file upload
*
* @param name - the name of the file part, expressed as a function
* @param filePath - the path of the file, either relative to the root of the classpath, or
* absolute, expressed as a Gatling Expression Language String
* @returns a new HttpRequestActionBuilder instance
*/
formUpload(name: (session: Session) => string, filePath: string): T;
/**
* Set a form file upload
*
* @param name - the name of the file part, expressed as a Gatling Expression Language String
* @param filePath - the path of the file, either relative to the root of the classpath, or
* absolute, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
formUpload(name: string, filePath: (session: Session) => string): T;
/**
* Set a form file upload
*
* @param name - the name of the file part, expressed as a function
* @param filePath - the path of the file, either relative to the root of the classpath, or
* absolute, expressed as a function
* @returns a new HttpRequestActionBuilder instance
*/
formUpload(name: (session: Session) => string, filePath: (session: Session) => string): T;
/**
* Set the content-type header for JSON
*
* @returns a new DSL instance
*/
asJson(): T;
/**
* Set the content-type header for XML
*
* @returns a new DSL instance
*/
asXml(): T;
}
export declare const requestWithBodyActionBuilderImpl: <T, J extends JvmRequestWithBodyActionBuilder<J, any>>(jvmBuilder: J, wrap: (_underlying: J) => T) => RequestWithBodyActionBuilder<T>;
export interface HttpRequestActionBuilder extends RequestWithBodyActionBuilder<HttpRequestActionBuilder>, RequestActionBuilder<HttpRequestActionBuilder>, ActionBuilder {
_underlying: JvmHttpRequestActionBuilder;
/**
* Apply some checks
*
* @param checks - the checks
* @returns a new HttpRequestActionBuilder instance
*/
check(...checks: CheckBuilder[]): HttpRequestActionBuilder;
/**
* Apply some checks if some condition holds true
*
* @param condition - the condition, expressed as a function
* @returns the next DSL step
*/
checkIf(condition: string): Condition<HttpRequestActionBuilder>;
/**
* Apply some checks if some condition holds true
*
* @param condition - the condition, expressed as a function
* @returns the next DSL step
*/
checkIf(condition: (session: Session) => boolean): Condition<HttpRequestActionBuilder>;
/**
* Have this request ignore the common checks defined on the HTTP protocol configuration
*
* @returns a new HttpRequestActionBuilder instance
*/
ignoreProtocolChecks(): HttpRequestActionBuilder;
/**
* Have this request ignore the common checks defined on the HTTP protocol configuration
*
* @returns a new HttpRequestActionBuilder instance
*/
silent(): HttpRequestActionBuilder;
/**
* Instruct the reporting engine to forcefully report stats about this request, ignoring HTTP
* protocol configuration
*
* @returns a new HttpRequestActionBuilder instance
*/
notSilent(): HttpRequestActionBuilder;
/**
* Disable automatic redirect following
*
* @returns a new HttpRequestActionBuilder instance
*/
disableFollowRedirect(): HttpRequestActionBuilder;
/**
* Set some resources to be fetched concurrently after the main request. Next action in the
* Scenario will be performed once all resources are fetched.
*
* @param res - the resources
* @returns a new HttpRequestActionBuilder instance
*/
resources(...res: HttpRequestActionBuilder[]): HttpRequestActionBuilder;
/**
* Override the default request timeout defined in gatling.conf
*
* @param timeout - timeout the timeout
* @returns a new HttpRequestActionBuilder instance
*/
requestTimeout(timeout: Duration): HttpRequestActionBuilder;
}
export declare const wrapHttpRequestActionBuilder: (_underlying: JvmHttpRequestActionBuilder) => HttpRequestActionBuilder;