Commits

Robert Brewer committed 37e319b

Speed tweak: you can now set max_header_size and max_request_size to 0 to explicitly skip using SizeWrappers.

Comments (0)

Files changed (2)

cherrypy/_cpwsgi.py

         _cpwsgiserver.HTTPRequest.__init__(self, socket, addr, server)
         mhs = int(cherrypy.config.get('server.max_request_header_size',
                                       500 * 1024))
-        self.rfile = httptools.SizeCheckWrapper(self.rfile, mhs)
+        if mhs > 0:
+            self.rfile = httptools.SizeCheckWrapper(self.rfile, mhs)
     
     def parse_request(self):
         try:
             if self.ready:
                 # Request header is parsed
                 # We prepare the SizeCheckWrapper for the request body
-                self.rfile.bytes_read = 0
                 script_name = self.environ.get('SCRIPT_NAME', '')
                 path_info = self.environ.get('PATH_INFO', '')
                 path = (script_name + path_info)
                     path = "global"
                 mbs = int(cherrypy.config.get('server.max_request_body_size',
                                               100 * 1024 * 1024, path=path))
-                self.rfile.maxlen = mbs
+                if mbs > 0:
+                    if isinstance(self.rfile, httptools.SizeCheckWrapper):
+                        self.rfile.bytes_read = 0
+                        self.rfile.maxlen = mbs
+                    else:
+                        self.rfile = httptools.SizeCheckWrapper(self.rfile, mbs)
 
 
 class WSGIServer(_cpwsgiserver.CherryPyWSGIServer):

cherrypy/test/benchmark.py

 
 class Root:
     def index(self):
-        return r"Hello, world\r\n"
+        return "Hello, world\r\n"
     index.exposed = True
     
     def sizer(self, size):
         'server.environment': 'production',
         'server.socket_host': 'localhost',
         'server.socket_port': 8080,
+        'server.max_request_header_size': 0,
+        'server.max_request_body_size': 0,
         },
     '/static': {
         'static_filter.on': True,
     if "-notests" in sys.argv:
         # Return without stopping the server, so that the pages
         # can be tested from a standard web browser.
-        run = lambda x: x
+        run = lambda: None
     else:
         def run():
             end = time.time() - start
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.