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