I'd like to use `httpProtocol` to configure my requests. But, I don't know the values that I want to put in the httpProtocol before the test runs, so I'm trying to figure out how to... lazily set up the httpProtocol, or... mutate the httpProtocol, or to set up a new httpProtocol... or something, after sending my first request. The first request comes back with the data I need to properly define the httpProtocol.
Basically, my first request is for an `access_token` as well as a user UUID. Following that, there will be 90 - 100 requests or so using the UUID in the url and requiring the `access_token` in the authorization header. I've found out how to use `saveAs` to put the access token and uuid into the `session`, but I don't know how to tell gatling to use them in the subsequent requests other than explicitly putting a header and url in every request. Here's a short version of what I'm trying to do...
val scn = scenario("load tests")
.exec(http("first request with important stuff in the response")
.post(authentication_url)
.check(jsonPath("$.user_id").exists.saveAs("user_id"))
.check(jsonPath("$.access_token").exists.saveAs("access_token"))
)
.exec( (session: Session) => {
// this is nonsense
val httpProtocol = http
.baseUrl("/.../${user_id}/...")
.authorizationHeader("auth ${access_token}")
})
.exec(http("90 more of these exist")
.get(needs_the_user_id + "something else different per request")
.header("Authorization", needs_the_access_token)
.check(bodyString.is(RawFileBody("expected_response.txt"))))
// repeat variations of the above request with gets, posts, puts, etc...
...
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)