Ticket #117 (closed task: fixed)
paste.httpexceptions always displays plaintext exceptions in Safari
| Reported by: | http://alastair.houghton.myopenid.com/ | Owned by: | ianb |
|---|---|---|---|
| Priority: | high | Milestone: | 1.4.1 |
| Component: | wareweb | Version: | 0.3 |
| Severity: | blocker | Keywords: | |
| Cc: |
Description
Safari doesn't explicitly list text/html in its http-accept header; instead, it just specifies */*. As a result, the existing behaviour of httpexceptions.py is flawed in that it will only ever display plaintext responses in Safari (along with any other client that exhibits this behaviour).
Here's a patch to fix it:
Index: httpexceptions.py
===================================================================
--- httpexceptions.py (revision 5118)
+++ httpexceptions.py (working copy)
@@ -228,7 +228,8 @@
headers = list(self.headers)
else:
headers = []
- if 'html' in environ.get('HTTP_ACCEPT',''):
+ accepts = environ.get('HTTP_ACCEPT','')
+ if 'html' in accepts or '*/*' in accepts:
replace_header(headers, 'content-type', 'text/html')
content = self.html(environ)
else:
Change History
Note: See
TracTickets for help on using
tickets.
