# Simulation Fails if response has no headers

**URL:** <https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198>\
**Category:** Gatling (Open-Source)\
**Created:** [December 13, 2012, 1:39pm UTC](https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198 "2012-12-13T13:39:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomcoder](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@randomcoder](https://community.gatling.io/u/randomcoder)\
**Post date:** [December 13, 2012, 1:39pm UTC](https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198/1 "2012-12-13T13:39:16Z")

</div>

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  
}

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [December 13, 2012, 1:54pm UTC](https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198/2 "2012-12-13T13:54:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![randomcoder](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@randomcoder](https://community.gatling.io/u/randomcoder)\
**Post date:** [December 13, 2012, 2:33pm UTC](https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198/3 "2012-12-13T14:33:04Z")

</div>

Hi,

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

Cheers,

RC

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [December 13, 2012, 2:44pm UTC](https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198/4 "2012-12-13T14:44:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![randomcoder](https://avatars.discourse-cdn.com/v4/letter/r/96bed5/32.png) [@randomcoder](https://community.gatling.io/u/randomcoder)\
**Post date:** [December 19, 2012, 11:57am UTC](https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198/5 "2012-12-19T11:57:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [December 19, 2012, 12:02pm UTC](https://community.gatling.io/t/simulation-fails-if-response-has-no-headers/198/6 "2012-12-19T12:02:32Z")

</div>

Hi,

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

[https://github.com/excilys/gatling/issues/877](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
