HTTP Request Builder: Methods, Bodies, and Headers
Build Gatling HTTP requests with GET, POST, PUT, DELETE, and more. Configure query params, headers, body types, form data, multipart parts, and transforms.
Use this file to discover all available pages before exploring further.
Every HTTP interaction in a Gatling simulation starts with the http(requestName) builder. The request name serves as the key for aggregating statistics in reports — requests sharing the same name across different scenario steps are combined. Once built, requests are passed to exec() to be attached to the scenario flow. All parameters throughout the builder — URLs, headers, body content — accept static strings, Gatling Expression Language (EL) strings, or session functions.
// static namehttp("requestName").get("https://gatling.io");// dynamic name from ELhttp("#{requestName}").get("https://gatling.io");// dynamic name from functionhttp(session -> session.getString("requestName")).get("https://gatling.io");
Request names can be dynamic, but avoid generating a very high number of distinct values. Too many unique request names place a heavy burden on the reporting module and dilute statistics to the point of meaninglessness.
Query parameters can be passed inline in the URL string or added individually via queryParam. Keys and values are URL-encoded by default.
// inline in URLhttp("Issues") .get("https://github.com/gatling/gatling/issues?milestone=1&state=open");// via queryParamhttp("Issues").get("https://github.com/gatling/gatling/issues") .queryParam("milestone", "1") .queryParam("state", "open");// with EL stringshttp("Issues").get("https://github.com/gatling/gatling/issues") .queryParam("milestone", "#{milestoneValue}") .queryParam("state", "#{stateValue}");// multiple values for a single keyhttp("name").get("/") .multivaluedQueryParam("param", List.of("value1", "value2"));// multiple params at oncehttp("name").get("/") .queryParamSeq(List.of( Map.entry("key1", "value1"), Map.entry("key2", "value2") ));
Add response checks to an individual request. These run in addition to any checks defined at the protocol level. Use ignoreProtocolChecks to skip protocol-level checks for a specific request.
http("name").get("/") .check(status().is(200));// skip protocol checks for this requesthttp("name").get("/") .ignoreProtocolChecks();
Body templates are resolved from the classpath. Place files under src/main/resources or src/test/resources in Maven/Gradle/sbt projects and reference them with a classpath path (e.g., data/payload.json), not a relative filesystem path.
StringBody
RawFileBody
ElFileBody
PebbleStringBody
PebbleFileBody
ByteArrayBody
InputStreamBody
Pass a text payload defined inline. The charset is taken from the Content-Type header, or from gatling.conf if not set. Supports static strings, EL strings, and functions.
Send raw file bytes as-is. This is the most efficient body type because bytes are cached and not transcoded. Suitable for binary protocols like Protobuf.
http("name").post("/") .body(RawFileBody("rawPayload.json"));// with EL pathhttp("name").post("/") .body(RawFileBody("#{payloadPath}"));
Load a text template from the classpath and resolve Gatling EL expressions within it before sending.
Pass a java.io.InputStream as the request body. The stream is read once and not cached, so use a function that produces a new stream for each virtual user.
Available part types mirror the full body types: StringBodyPart, RawFileBodyPart, ElFileBodyPart, PebbleStringBodyPart, PebbleFileBodyPart, and ByteArrayBodyPart.
Attach subordinate resource requests to a main request. They are fetched concurrently (capped by maxConnectionsPerHost for HTTP/1.1, uncapped for HTTP/2) and the scenario pauses until all complete.
Execute a standalone group of requests concurrently outside of a main request context. Use httpConcurrentRequests when you want to fire multiple independent requests at the same time without any parent request. Concurrency follows the same rules as resources — capped by maxConnectionsPerHost for HTTP/1.1 and uncapped for HTTP/2.
Mark a request as silent so it is excluded from reports and error triggers, or mark a specific resource as not silent when resources are globally silenced.
http("name").get("/").silent();// mark a specific resource as not silenthttp("name").get("/") .resources( http("resource").get("/assets/images/img1.png").notSilent() );