Skip to content

Response Headers should be allowed to be null (or at least empty if not set) #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
randomcoder opened this issue Dec 13, 2012 · 10 comments

Comments

@randomcoder
Copy link

Whilst running a Gatling test on a server that does not generate any headers at all I get 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)

The problem is that the headers in the response are null which causes the exception to be thrown.

However, the HTTP Response RFC states that the headers are optional and that only the status line and a single CRLF are required.

The RFC is at http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

with the relevant Augmented BNF being:

Response = Status-Line
           *(( general-header
           response-header
           entity-header ) CRLF)
           CRLF
           [ message-body ]

where the *((...)) indicates that 0 or more of the elements after the * are permitted.

Therefore it is not in keeping with the standard to throw an exception if there are no headers, simply to use empty headers if there are none.

@slandelle
Copy link
Contributor

@jfarcand I can work on a fix for this. Do you have any objection if I replace everywhere throw IllegalStateException(HEADERS_NOT_COMPUTED) with return null/empty list/ empty FluentCaseInsensitiveStringsMap?

@jfarcand
Copy link
Contributor

@slandelle +1 !

@slandelle
Copy link
Contributor

OK, will do.

rlubke pushed a commit that referenced this issue Dec 18, 2012
rlubke added a commit that referenced this issue Dec 18, 2012
Fix proposal for #182 against 1.7.x
rlubke pushed a commit that referenced this issue Dec 18, 2012
rlubke added a commit that referenced this issue Dec 18, 2012
Fix proposal for #182 against master
@rlubke rlubke closed this as completed Dec 18, 2012
@rlubke
Copy link
Contributor

rlubke commented Dec 18, 2012

Thanks for the submission!

@slandelle
Copy link
Contributor

You're welcome. Thanks for this great project!

@slandelle
Copy link
Contributor

@jfarcand @rlubke This bug was originally reported against Gatling and I'm about to cut the next release. Do you think it would be possible to release 1.7.9, please? Otherwise, I can ship a custom AHC build.

Cheers,

Stéphane

@slandelle
Copy link
Contributor

I found a bug with what I've done, since I didn't realize that AsyncHttpProviderUtils.parseCharset could return null.
I'll submit a patch in a few minutes, sorry.

@jfarcand
Copy link
Contributor

Salut, no problem, when do you need it? I can do it anytime this week. A+

@slandelle
Copy link
Contributor

I plan to release on Thursday (France time). Could you release tomorrow, please?
Merci beaucoup (les bières vont commencer à s'amasser)!

@jfarcand
Copy link
Contributor

Parfait! I wil cut the release tomorrow morning.

cs-workco pushed a commit to cs-workco/async-http-client that referenced this issue Apr 13, 2023
* add version to response

* fix API breakage by deprecating old init

* review fix: use renamed instead of message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants