Perservere returns application/javascript Content-Type not accepted by request

4 views
Skip to first unread message

Stephen Bannasch

unread,
Nov 21, 2009, 2:59:57 PM11/21/09
to persevere...@googlegroups.com
I'm playing around with the SproutCore app Tasks:

http://github.com/suvajitgupta/Tasks

and it is sending the following request to Perservere:

GET http://localhost:4400/tasks-server/user?loginName=%27SA%27&password=%27%27

with the following in the Accept header:

application/json, text/javascript, application/xml, text/xml, text/html, */*

Perservere however returns an 'application/javascript' Content-Type:

application/javascript; charset=UTF-8;schema=Class/user

With a body that looks like this:

{}&&[
{"id":"user/1",
"name":"System Admin",
"loginName":"SA",
"role":"_Manager",
"password":""
}
]

This is not valid json and 'application/javascript' is not listed an an accepted Content-Type in the request. In this case the
result is an application error.

The request in the Accept header also claims it accepts these types:

text/javascript, application/xml, text/xml, text/html, */*

I'd call that an error in the app itself because those content types will cause an error unless the response is json
masquerading as one of these types -- which certainly wouldn't be the case for a response from Perservere.

I think the app should be refactored to more accurately describe in it's requests to Perservere what Content-Type it is
expecting.

I also think Perservere needs to be fixed to not return Content-Types that aren't listed in the request Accept header.

What do people here think about this behavior from Perservere?

Kris Zyp

unread,
Nov 22, 2009, 7:01:33 PM11/22/09
to persevere...@googlegroups.com
I don't know why I didn't get a moderation until just now (its a pain to
have to moderate groups now), but we discussed this issue on IRC. */* is
a wildcard, so Persevere is correct (per RFC 2616) in returning
application/javascript in response to the given Accept header.
Kris
> --
>
> You received this message because you are subscribed to the Google Groups "Persevere" group.
> To post to this group, send email to persevere...@googlegroups.com.
> To unsubscribe from this group, send email to persevere-frame...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/persevere-framework?hl=.
>
>
>

Stephen Bannasch

unread,
Nov 23, 2009, 1:26:00 AM11/23/09
to persevere...@googlegroups.com
At 5:01 PM -0700 11/22/09, Kris Zyp wrote:
>I don't know why I didn't get a moderation until just now (its a pain to
>have to moderate groups now), but we discussed this issue on IRC. */* is
>a wildcard, so Persevere is correct (per RFC 2616) in returning
>application/javascript in response to the given Accept header.
>Kris

Yes, I agree.

It was confusing to me because I was quickly modifying someone else's app -- I knew they were consuming json, and 'application/json' was first on the list in the request's Accept header -- but of course first on the Accept header list means nothing -- the Q value is needed to specify a preference.

I've patched the app to only accept 'application/json' and fixed the other part in the app that "normalized" the response.

Thanks for the help on IRC!

Without knowing more about all the ways folks use Persevere I still think it would be reasonable to return 'application/json' (but RFC 2616 certainly doesn't require or even suggest that).

But it definitely made *no* sense for the app I was patching to be sending out this for the Accept header:

Kris Zyp

unread,
Nov 23, 2009, 10:32:33 AM11/23/09
to persevere...@googlegroups.com


Stephen Bannasch wrote:
> At 5:01 PM -0700 11/22/09, Kris Zyp wrote:
>
>> I don't know why I didn't get a moderation until just now (its a pain to
>> have to moderate groups now), but we discussed this issue on IRC. */* is
>> a wildcard, so Persevere is correct (per RFC 2616) in returning
>> application/javascript in response to the given Accept header.
>> Kris
>>
>
> Yes, I agree.
>
> It was confusing to me because I was quickly modifying someone else's app -- I knew they were consuming json, and 'application/json' was first on the list in the request's Accept header -- but of course first on the Accept header list means nothing -- the Q value is needed to specify a preference.
>
> I've patched the app to only accept 'application/json' and fixed the other part in the app that "normalized" the response.
>
> Thanks for the help on IRC!
>
> Without knowing more about all the ways folks use Persevere I still think it would be reasonable to return 'application/json' (but RFC 2616 certainly doesn't require or even suggest that).
>
The rationale for Persevere's preference to application/javascript is
that it provides a more accurate representation of the data since the
data on the server is actually JavaScript objects. And
application/javascript allows for more complete serialization by using
real JS dates and functions (as well as some other misc things like NaN,
undefined, etc) to be transferred (without any need for special
conventions for interpreting).
Kris

Reply all
Reply to author
Forward
0 new messages