I am trying to create scenario containing a post request with parameters that comes from a previous request.
For now I store those parameters as a list in the session using a regexp on the first request.
I am new to scala and gatling and I cannot find a way to create the post request using the “list” stored in the session and “dynamically” add the parameters.
My first idea is to loop on the list and add params to a base PostHttpRequestBuilder.
Regarding the scala code you wrote, it works only if your parameter values list is static, ie exists when building the Simulation.
In that case, you were almost there: the complete requestBuilder is the value returned by foldLeft. You can either “exec” it or add checks or whatever on it.
With the new API, you can write .multiValuedParam(“foo”, List(“bar”, “baz”))
I know but the list was actually extracted from the session.
I used static vars so I could reference the list from everywhere in the simulation builder.
The thing is the initial baseRequestBuilder “var” reference was passed to the exec at the end and I couldn’t make the new “var” reference get executed by an exec.
As I told you I am new to scala and functional programming :).
Well, lack of multivalued parameters support was definitely an issue, so I added in the DSL.
What you propose would actually be quite the Pandora box, so I still need to see a concrete use case for this.
What you’d need would be a good understand of Gatling inner HTTP API and that we add a hook that let you access the ProtocolConfigurationRegistry required for building an HttpRequestBuilder.
The current hook exec(Session => Session) doesn’t have this parameter.
So, it is almost feasible, I’d just like to get a real use case for this.