Request body being stripped out before sending when using Scalate Template on Scala 2.10


I’m setting up a load test of a Scala 2.10 Spray project, using Gatling 2.0.0-SNAPSHOT. I used the recorder to setup a basic scenario hitting my REST service, which when replayed works fine. I need to use the Scalate template feature however to tweak each request with some dynamic data, and so I switched to using the overloaded fileBody call which works with a Scalate template:

val scn = scenario(“Scenario1”)
.fileBody(“event”, Map(“user” → “${user}”))


When using the template, I was not getting any request hitting the spray server. I turned on debugging and saw that a connection is made from Gatling, but it never receives the full request and logs it (as it does fine when using a simple file body with no template). So I hooked up Gatling to use a Charles proxy, and captured the event on the wire. What I found was that when using the Scalate overload, the body of the request is missing; it is empty. When using the normal fileBody, it is present and correct. Everything else is identical in both (headers etc, including correctly set Content-Length).

I traced through everything with the debugger, and found that the Scalate template is resolved perfectly and the values are substituted in to make the body that I’m expecting, but at the last minute the body is stripped out, before the request is sent on the wire. It seems like this is occurring in AbstractHttpRequestWithBodyAndParamsBuilder:

if (paramsAttributes.uploadedFiles.isEmpty)
else {

With the overload, it hits the first condition, and then does a:
HttpHelper.httpParamsToFluentMap(paramsAttributes.params, session).map(requestBuilder.setParameters)

Where this ultimately hits:
request.stringData = null;

in resetNonMultipartData() of RequestBuilderBase.

So it appears that the string body is stripped out :slight_smile:

If there is a work around (or I’ve missed something) that would be great to know, otherwise hope this helps fix the issue. I realise I’m on the edge using the latest snapshot, but want to use the awesome power of Gatling on a Scala 2.10 project :slight_smile:


Hi Tim,

I have been able to reproduce your issue … but I’m not yet sure on how to fix that. I’ll keep you posted.

Thanks for reporting !

OK, found it.

The regression was introduced here :
And here is my fix :

Thanks for the report and the analysis !

Have a nice week-end

Brilliant, thanks Nicolas for the super quick fix!

Can confirm the latest snapshot is now working for me :slight_smile:

Thanks again for an awesome tool!