Hi all,

I'm writing error handling middleware for my application which returns JSON 
errors and I'm having some issues getting the returned content to be displayed 
in Firefox. I posted the implementation of the error handler to the list 
earlier 
(here's a link http://tinyurl.com/jsonerrorhandler)

If I fetch a url which causes an error using Firefox I see an empty page -- as 
though no content was being returned by the server. However, if I fetch the 
same 
url using curl or through a telnet session I can see that headers and content 
are being returned.

Here's the output from curl
 > curl http://localhost:5072/queues
{"status": {"code": 400, "response": "Bad Request"}, "request": {"url": 
"http://localhost:5072/queues";, "params": {}}, "error": {"code": 40001, 
"class": 
"RequestError: The server cannot complete the request since it is malformed or 
incorrect.", "detail": {"msg": "Need both start and end to fetch a range", 
"alternatives": {}, "in": {"start": null, "end": null}}}}

And here's a sample telnet session, which shows the headers returned
 > telnet localhost 5072
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /queues HTTP/1.1
Host: localhost:5072
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) 
Gecko/2009032711 
Ubuntu/8.10 (intrepid) Firefox/3.0.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

HTTP/1.0 400 Bad Request
Server: PasteWSGIServer/0.5 Python/2.6.1
Date: Wed, 22 Apr 2009 00:39:53 GMT
content-type: application/json
content-length: 364

{"status": {"code": 400, "response": "Bad Request"}, "request": {"url": 
"http://localhost:5072/queues";, "params": {}}, "error": {"code": 40001, 
"class": 
"RequestError: The server cannot complete the request since it is malformed or 
incorrect.", "detail": {"msg": "Need both start and end to fetch a range", 
"alternatives": {}, "in": {"start": null, "end": null}}}}

Any suggestions on what might be going wrong here? I'm successfully returning 
JSON which can be seen in Firefox in non-error conditions, i.e. 2xx return 
codes. Getting it working right under error conditions seems to be eluding me. 
Perhaps Firefox is ignoring the content when the HTTP status is not in the 
successful range.

I'd appreciate any advice on how to proceed.
Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to