Commits

Robert Brewer committed 07f3aad

Split process_request_body into two flags instead (new request.body_read flag to signal that the request body has already been read).

Comments (0)

Files changed (1)

     rfile = None
     process_request_body = True
     body = None
+    body_read = False
     
     # Dispatch attributes
     script_name = ""
                 self.tool_up()
                 self.hooks.run('on_start_resource')
                 
-                if self.process_request_body:
+                if self.process_request_body and not self.body_read:
                     # Check path-specific methods_with_bodies.
                     meths = self.config.get("methods_with_bodies", ("POST", "PUT"))
                     self.process_request_body = self.method in meths
                 self.hooks.run('before_request_body')
                 if self.process_request_body:
                     self.process_body()
-                    # Guard against re-reading body on InternalRedirect
-                    self.process_request_body = False
                 
                 self.hooks.run('before_main')
                 if self.handler:
     
     def process_body(self):
         """Convert request.rfile into request.params (or request.body)."""
+        # Guard against re-reading body (e.g. on InternalRedirect)
+        if self.body_read:
+            return
+        self.body_read = True
+        
         # FieldStorage only recognizes POST, so fake it.
         methenv = {'REQUEST_METHOD': "POST"}
         try:
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 ProjectModifiedEvent.java.
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.