Hello. I am starting to use Gatling, coming from CloudTest and JMeter. I am implementing the Page Object pattern in my Gatling framwork, and wondering how best to deal with headers. Currently in my page objects, I may have several different headers defined as below from the recording. Of course there will be a lot of repeated code between pages, as many requests will use similar or identical headers. Without overcomplicating, is there a best practice for easily maintaining headers while avoiding redundant code?
val headers_1 = Map(
“Accept” → “text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8”,
“Connection” → “keep-alive”,
“Upgrade-Insecure-Requests” → “1”)
val headers_2 = Map(
“Accept” → “/”,
“Connection” → “keep-alive”,
“X-Requested-With” → “XMLHttpRequest”)
val headers_3 = Map(
“Accept” → “image/webp,image/apng,image/,/*;q=0.8”,
“Connection” → “keep-alive”)