acceptsStarStar broken for weighted accept entries #1186

Open
indrajitr opened this Issue Jan 26, 2012 · 1 comment

Comments

Projects
None yet
3 participants
@indrajitr
Member

indrajitr commented Jan 26, 2012

I have a simple feed that uses serveJx to select the return type (json
or xml) based on the request Accept header and the extension (.json
or .xml). This generally works fine except in one case I've found. If
the extension is .xml, I get back json. I have traced this back to a
bug in Req.acceptsStarStar in version 2.4-M4, which looks like this:

lazy val acceptsStarStar : Boolean = accepts.map(_ == "/") openOr
false

In my case accepts = Full(text/html,application/xhtml+xml,application/
xml;q=0.9,/;q=0.8). Note that the last entry is weighted. Thus, the
above comparison to "/" fails and acceptsStarStar returns false,
when in fact it should be true because "/" is present, just with a
weight, which is a valid format (see weightedAccepts in Req).

The full call stack is:

serveJx
jxSel
jsonResponse_?
acceptsStarStar

Weighted accept is List(ContentType(text,html,0,Empty,List()),
ContentType(application,xhtml+xml,1,Empty,List()),
ContentType(application,xml,2,Full(0.9),List()), ContentType(,,
3,Full(0.8),List()))

Thanks.

@github-importer

This comment has been minimized.

Show comment Hide comment

@ghost ghost assigned dpp Mar 1, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment