[wsgi] Honor the 'CONTENT_TYPE' wsgi variable
authorChristophe de Vienne <christophe@unlish.com>
Thu, 24 Jul 2014 20:53:21 +0200
changeset 9939 46a8ed48636f
parent 9936 5dbf45204109
child 9940 292f786009ba
[wsgi] Honor the 'CONTENT_TYPE' wsgi variable See http://legacy.python.org/dev/peps/pep-0333/#environ-variables Closes #4191812
wsgi/request.py
wsgi/test/unittest_wsgi.py
--- 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'))