# HG changeset patch # User Christophe de Vienne # Date 1406228001 -7200 # Node ID 46a8ed48636f4916c2604a9d4e123dc5f69860a6 # Parent 5dbf45204109fb2efc57687f15abbaff07fbd156 [wsgi] Honor the 'CONTENT_TYPE' wsgi variable See http://legacy.python.org/dev/peps/pep-0333/#environ-variables Closes #4191812 diff -r 5dbf45204109 -r 46a8ed48636f wsgi/request.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() diff -r 5dbf45204109 -r 46a8ed48636f wsgi/test/unittest_wsgi.py --- /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'))