Changeset 1175
- Timestamp:
- 06/29/06 14:15:43
- Files:
-
- trunk/cherrypy/_cprequest.py (modified) (2 diffs)
- trunk/cherrypy/test/test_core.py (modified) (5 diffs)
- trunk/cherrypy/test/webtest.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cprequest.py
r1170 r1175 208 208 209 209 if self.process_request_body: 210 # Check path-specific methods_with_bodies. 211 meths = self.config.get("methods_with_bodies", ("POST", "PUT")) 212 self.process_request_body = self.method in meths 213 210 214 # Prepare the SizeCheckWrapper for the request body 211 215 mbs = int(self.config.get('server.max_request_body_size', … … 240 244 241 245 self.method = method 242 self.process_request_body = method in ("POST", "PUT")243 244 246 self.path = path 245 247 self.query_string = qs trunk/cherrypy/test/test_core.py
r1168 r1175 16 16 17 17 defined_http_methods = ("OPTIONS", "GET", "HEAD", "POST", "PUT", "DELETE", 18 "TRACE", "CONNECT" )18 "TRACE", "CONNECT", "PROPFIND") 19 19 20 20 … … 113 113 114 114 def index(self): 115 raise NameError( )115 raise NameError("redirect_test") 116 116 index.exposed = True 117 117 error = Error() … … 373 373 'server.max_request_header_size': 500, 374 374 }) 375 cherrypy.tree.mount(root, conf={'/': {'log_access_file': log_access_file}}) 375 appconf = { 376 '/': {'log_access_file': log_access_file}, 377 '/method': {'methods_with_bodies': ("POST", "PUT", "PROPFIND")}, 378 } 379 cherrypy.tree.mount(root, conf=appconf) 376 380 377 381 … … 766 770 767 771 def testHTTPMethods(self): 772 helper.webtest.methods_with_bodies = ("POST", "PUT", "PROPFIND") 773 768 774 # Test that all defined HTTP methods work. 769 775 for m in defined_http_methods: … … 785 791 786 792 # Request a PUT method with a file body 787 h = [("Content-type", "text/plain"), 788 ("Content-Length", "27")] 789 790 self.getPage("/method/request_body", headers=h, method="PUT", 791 body="one thing on top of another") 792 self.assertBody("one thing on top of another") 793 b = "one thing on top of another" 794 h = [("Content-Type", "text/plain"), 795 ("Content-Length", str(len(b)))] 796 self.getPage("/method/request_body", headers=h, method="PUT", body=b) 797 self.assertStatus(200) 798 self.assertBody(b) 799 800 # Request a custom method with a request body 801 b = ('<?xml version="1.0" encoding="utf-8" ?>\n\n' 802 '<propfind xmlns="DAV:"><prop><getlastmodified/>' 803 '</prop></propfind>') 804 h = [('Content-Type', 'text/xml'), 805 ('Content-Length', str(len(b)))] 806 self.getPage("/method/request_body", headers=h, method="PROPFIND", body=b) 807 self.assertStatus(200) 808 self.assertBody(b) 793 809 794 810 # Request a disallowed method trunk/cherrypy/test/webtest.py
r1167 r1175 324 324 325 325 326 methods_with_bodies = ("POST", "PUT") 326 327 327 328 def cleanHeaders(headers, method, body, host, port): … … 340 341 headers.append(("Host", "%s:%s" % (host, port))) 341 342 342 if method in ("POST", "PUT"):343 if method in methods_with_bodies: 343 344 # Stick in default type and length headers if not present 344 345 found = False

