Avoid duplicate queryParam and header in exec

Hi @dariush,

As (nearly) anything is immutable in Gatling DSL, you can easily make your own function.

public HttpBuilder withCommonParam(HttpBuilder httpBuilder) {
  return httpBuilder
    .header(“Content-Type”, “application/xml”)
    .queryParam(“key”, “value”)
    .queryParam(“key”, “#{value}”)
    .queryParam(“key”, “#{value}”)
    .queryParam(“key”, “#{value}”);
}

// call site
.exec(withCommonParams(http("Statement 1").post("https://blabla").header("id", "#{id}"));

Cheers!

2 Likes