Simulation Fails if response has no headers

When running a simulation against a server that does not generate any headers in its responses (which conforms to the HTTP 1.1 RFC) the simulation will always fail with the following exception:

java.lang.IllegalStateException: Response’s headers hasn’t been computed by your AsyncHandler.
at com.ning.http.client.providers.netty.NettyResponse.getCookies(NettyResponse.java:184)
at com.excilys.ebi.gatling.http.response.ExtendedResponse.getCookies(ExtendedResponse.scala:89)
at com.excilys.ebi.gatling.http.ahc.GatlingAsyncHandlerActor.com$excilys$ebi$gatling$http$ahc$GatlingAsyncHandlerActor$$processResponse(GatlingAsyncHandlerActor.scala:198)
at com.excilys.ebi.gatling.http.ahc.GatlingAsyncHandlerActor$$anonfun$receive$1.apply(GatlingAsyncHandlerActor.scala:107)
at com.excilys.ebi.gatling.http.ahc.GatlingAsyncHandlerActor$$anonfun$receive$1.apply(GatlingAsyncHandlerActor.scala:83)
at akka.actor.Actor$class.apply(Actor.scala:318)
at com.excilys.ebi.gatling.core.action.BaseActor.apply(BaseActor.scala:23)
at akka.actor.ActorCell.invoke(ActorCell.scala:626)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:197)
at akka.dispatch.Mailbox.run(Mailbox.scala:179)
at akka.dispatch.ForkJoinExecutorConfigurator$MailboxExecutionTask.exec(AbstractDispatcher.scala:516)
at akka.jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:259)
at akka.jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975)
at akka.jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1479)
at akka.jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)

This is because the headers in the underlying NettyResponse are null and the getCookies() emthod performs a check for this.

Is this behaviour intended, as it seems that the ning library assumes there will always be headers present although this is not strictly required.

I think the fix for this would be to get the cookies in a try catch and generate an empty cookies list

So the code in GatlingAsyncHandlerActor.scala line 197 would be replaced with

val cookiesList = try {
response.getCookies.toList
} catch {
e: IllegalStateException => List.empty
}

val sessionWithUpdatedCookies = CookieHandling.storeCookies(session, response.getUri, cookiesList)

Unfortunately I am at work currently so cannot easily create a fork & pull request but can raise an issue if that is better.

Regards,

RC

Hi RC,

Actually, the best way to fix this would be to... fix this in AHC.
Having an abnormal exception is something expensive, so I'd rather not have
it in the first place and fix the problem upstream.

Could you either open an issue on AHC, or point the exact RFC chapter so I
can open it, please? Once it's fixed, I'll either ask Jean-François to
release, or deploy a snapshot.

Thanks for reporting,

Stéphane

Hi,

I have opened issue https://github.com/AsyncHttpClient/async-http-client/issues/182 for this.

Cheers,

RC

Thanks. Is this a blocker for you? Do you want me to deploy a custom AHC?

Hi,

No this is not a blocker at the moment. We have modified our system under test to include default headers for now (which is a good thing anyway), but a fix would be greatly appreciated when it is ready.

Cheers,

RC

Hi,

It looks like you haven’t checked the issues:
https://github.com/AsyncHttpClient/async-http-client/issues/182

https://github.com/excilys/gatling/issues/877

I’ve fixed the issue in async-http-client, and Jean-François Arcand has kindly released 1.7.9 today.
Gatling master already uses AHC 1.7.9 and we hope to release Gatling 1.4.0 tomorrow.

Cheers,

Stéphane