Robert Brewer committed ca94720

Moved request.body construction before config namespaces so 'request.body' config entries work.

Comments (0)

Files changed (2)


                     # Make a copy of the class hooks
                     self.hooks = self.__class__.hooks.copy()
                     self.toolmaps = {}
                     self.stage = 'get_resource'
+                    self.body = _cpreqbody.RequestBody(
+                        self.rfile, self.headers, request_params=self.params)
                     self.stage = 'on_start_resource'
                     # Process the body
-                    self.body = _cpreqbody.RequestBody(
-                        self.rfile, self.headers, request_params=self.params)
                     if self.process_request_body:
                         if self.method not in self.methods_with_bodies:
                             self.process_request_body = False


             return self.db = True
+        def plain(self, x):
+            return x
+ = True
+        plain._cp_config = {'request.body.attempt_charsets': ['utf-16']}
         favicon_ico =
                         filename=os.path.join(localDir, '../favicon.ico'))
         self.assertBody(open(os.path.join(localDir, "static/dirback.jpg"),
+    def test_request_body_namespace(self):
+        self.getPage("/plain", method='POST', headers=[
+            ('Content-Type', 'application/x-www-form-urlencoded'),
+            ('Content-Length', 13)],
+            body='\xff\xfex\x00=\xff\xfea\x00b\x00c\x00')
+        self.assertBody("abc")
 class VariableSubstitutionTests(unittest.TestCase):
     def test_config(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.