Chunked Encoding

so I have a large file which I need manipulate to generate some jsons as load. We also compress the request before send out, so the current code looks like the following and it works.

.feed(MyFeeder)
.tryMax(10, “retry”) {
pause(session=>calcPause(session(“retry”).as[Int]))
exec(
http(“Create”)
.post("/someObject")
.headers(httpHeaders)
.body(StringBody("${payload}"))
.processRequestBody(gzipBody)
.check(status.is(200))
)
}.exitHereIfFailed

Now, We want to chunk the request, since I want to send very large amount of jsons as one request, I wonder if the following code does the trick?

.feed(MyFeeder)
.tryMax(10, “retry”) {
pause(session=>calcPause(session(“retry”).as[Int]))
exec(
http(“Create”)
.post("/someObject")
.headers(httpHeaders)
.body(StringBody("${payload}"))
.processRequestBody(gzipBody)
.processRequestBody(streamBody)
.check(status.is(200))
)
}.exitHereIfFailed

Liang

I have several questions.

First: why do you want to use chunked transfer encoding? Is it because that’s how the application you want to simulate work?
Chunked transfer encoding is about not knowing the final Content-Length, even without, the body will still be sent in chunks (TCP).

Then, how does your feeder work? Is it one provided by Gatling, such as csv?
If so, the whole data is loaded in memory, so you could perform compression before starting the Simulation, with Feeder’s convert method (and now I realize we forgot to document it…).

Finally, if you really want to do it your way, you have to chain the processors, otherwise you’re just replacing the previous one:
processRequestBody(streamBody andThen gzipBody)

  1. yes. The process we try to develop itself is stream based. In order to make the test close to real env, we store the sample data in very large csv files.
  1. We implemented next as reads the records from csv files in turn and create the jsons in fly to mimic a streamed command source. No, we implement the feeder instead of use the existed one in gatling.
  2. That is what I am looking for.

Thanks.

Liang