[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
See http://legacy.python.org/dev/peps/pep-0333/#environ-variables
Closes #4191812
--- a/wsgi/request.py Tue Jul 29 16:26:09 2014 +0200
+++ b/wsgi/request.py Thu Jul 24 20:53:21 2014 +0200
@@ -59,6 +59,8 @@
headers_in = dict((normalize_header(k[5:]), v) for k, v in self.environ.items()
if k.startswith('HTTP_'))
+ if 'CONTENT_TYPE' in environ:
+ headers_in['Content-Type'] = environ['CONTENT_TYPE']
https = environ.get("HTTPS") in ('yes', 'on', '1')
post, files = self.get_posted_data()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/wsgi/test/unittest_wsgi.py Thu Jul 24 20:53:21 2014 +0200
@@ -0,0 +1,14 @@
+import webtest.app
+
+from cubicweb.devtools.webtest import CubicWebTestTC
+
+from cubicweb.wsgi.request import CubicWebWsgiRequest
+
+
+class WSGIAppTC(CubicWebTestTC):
+ def test_content_type(self):
+ r = webtest.app.TestRequest.blank('/', {'CONTENT_TYPE': 'text/plain'})
+
+ req = CubicWebWsgiRequest(r.environ, self.vreg)
+
+ self.assertEqual('text/plain', req.get_header('Content-Type'))