From e0d046c51f040d40d5d78d78294c658d8677f528 Mon Sep 17 00:00:00 2001
From: Samuele Kaplun <samuele.kaplun@cern.ch>
Date: Thu, 19 Jan 2012 11:33:22 +0100
Subject: [PATCH] WebStyle: use application/xhtml+xml when supported
* Invenio is currently using XHTML. Therefore, following W3C
recommendations, if a browser explicitly declare it accepts
application/xhtml+xml mimetype, Invenio should set this
content type rather than text/html.
See: <http://www.w3.org/TR/xhtml-media-types/#media-types>
(closes #180)
---
modules/webstyle/lib/webinterface_handler_wsgi.py | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/modules/webstyle/lib/webinterface_handler_wsgi.py b/modules/webstyle/lib/webinterface_handler_wsgi.py
index c6cdb9c..f7bbe29 100644
|
a
|
b
|
class SimulatedModPythonRequest(object): |
| 195 | 195 | self.__buffer = '' |
| 196 | 196 | |
| 197 | 197 | def set_content_type(self, content_type): |
| | 198 | if content_type.startswith('text/html') and "application/xhtml+xml" in self.__headers_in.get('Accept', ''): |
| | 199 | ## The W3C recommends that: |
| | 200 | ## <http://www.w3.org/TR/xhtml-media-types/#media-types> |
| | 201 | ## If the Accept header explicitly contains application/xhtml+xml |
| | 202 | ## (with either no "q" parameter or a positive "q" value) |
| | 203 | ## deliver the document using that media type. |
| | 204 | content_type = content_type.replace('text/html', "application/xhtml+xml") |
| | 205 | |
| 198 | 206 | self.__headers['content-type'] = content_type |
| 199 | 207 | if self.__is_https: |
| 200 | 208 | if content_type.startswith("text/html") or content_type.startswith("application/rss+xml"): |