Happy to help.
Indeed content should also, for now I json.dumps things..
Just a question, where is the tracker ? This one seems ... not functional ?
http://code.google.com/p/web2py-issuetracker/updates/list
Br.
On 16 Apr 2012, at 16:19, Jonathan Lundell wrote:
> On Apr 16, 2012, at 7:02 AM, Massimo Di Pierro wrote:
>> Shame on me. Than it is a bug. Please open a ticket on google code. web2py
>> sets the content-type correctly in gluon/main.html but it seems to lose it
>> when an HTTP exception is raised.
>
> It's not just that the content type should be set to text/json; the content
> itself needs to be JSON.
>
> This is slightly tricky when web2py is generating the response (as in a 5xx
> error), since the exact nature of a JSON response depends on the content of
> the JSON request (we're supposed to set the id to the id of the request, for
> example, though null is OK if the id is not known). I think it's safe to
> return a JSON-RPC 2.0 error response.
>
>>
>> On Monday, 16 April 2012 08:56:07 UTC-5, Joseph.Piron wrote:
>> Json indeed :)
>>
>> On 16 Apr 2012, at 15:44, Jonathan Lundell wrote:
>>
>>> On Apr 16, 2012, at 6:24 AM, Massimo Di Pierro wrote:
>>>> Because IE browsers, when they receive a error page (HTTP x!=200) and the
>>>> content is less than a certain size, they choose to ignore the content and
>>>> display an uninformative canned message instead. web2py injects in the
>>>> content an html comment to make it just long enough so that IE browser do
>>>> not ignore the comment. This is important for example so that IE displays
>>>> web2py tickets instead of a generic error page.
>>>
>>> Except that this is a JSON request, not HTML.
>>>
>>>>
>>>> On Monday, 16 April 2012 07:24:46 UTC-5, Joseph.Piron wrote:
>>>> Hi gents !
>>>>
>>>> I was working on an extjs client intended to discuss with web2py when I
>>>> stumbled upon this weird behaviour:
>>>>
>>>> with my client calling "PUT /defaut/api/alarms/1.json", I want the server
>>>> to respond a 409 error code with good json return {success: false, errors:
>>>> {...}}
>>>> and use raise HTTP(409, {"success":False, "errors":{...}}) to generate
>>>> this error.
>>>> Unfortunately, even if the call has been done with a ".json", the
>>>> content-type header of the response is set to "text/html" and thus, the
>>>> code adds a
>>>> <!--
>>>> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>> //-->
>>>>
>>>> at the end for a 4xx code (not for a 5xx code, which works for me).
>>>> Shouldn't the content-type be set to text/json or something similar ?
>>>>
>>>> Thanks for your support !
>>>
>>>
>>
>
>