Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 585

Show
Ignore:
Timestamp:
09/01/05 19:06:36
Author:
mikerobi
Message:

The maximum size of a post body can know be limited using sever.maxRequestSize, this does not test the header size! (yet)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cpcgifs.py

    r321 r585  
    11import cgi 
     2import cherrypy 
    23 
     4try: 
     5    from threading import local 
     6except ImportError: 
     7    from cherrypy._cpthreadinglocal import local 
    38 
     9class LocalInt: 
     10    def __init__(self, value): 
     11        self.__local = local() 
     12        self.__local.value = value 
     13 
     14    def __int__(self): 
     15        return self.__local.value 
     16 
     17    def __nonzero__(self): 
     18        return bool(self.__local.value) 
     19     
     20    def __str__(self): 
     21        return str(self.__local.value) 
     22     
    423class FieldStorage(cgi.FieldStorage): 
    5      
     24    def __init__(self, *args, **kwds): 
     25        maxlen = cherrypy.config.get('server.maxRequestSize') 
     26        cgi.maxlen = LocalInt(maxlen) 
     27         
     28        try: 
     29            cgi.FieldStorage.__init__(self, *args, **kwds) 
     30        except ValueError: 
     31            ec = cherrypy._cperror.HTTPClientError 
     32            raise ec(status=413) 
     33 
    634    def read_lines_to_eof(self): 
    735        """Internal: read lines until EOF.""" 
  • trunk/cherrypy/config.py

    r565 r585  
    5454    'server.reverseDNS': False, 
    5555    'server.threadPool': 0, 
     56 
     57    'server.maxRequestSize' : 0, # 0 == unlimited 
    5658    } 
    5759 

Hosted by WebFaction

Log in as guest/cpguest to create tickets