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

Changeset 894

Show
Ignore:
Timestamp:
12/29/05 12:33:13
Author:
fumanchu
Message:

Fix for #421 (Incorrect border condition in readline of SizeCheckWrapper?).

Files:

Legend:

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

    r843 r894  
    416416 
    417417class SizeCheckWrapper(object): 
    418     """ Wrapper around an rfile object. For each data reading method, 
    419         it reads the data but it checks that the size of the data doesn't 
    420         exceed a certain limit 
    421     """ 
     418    """Wraps a file-like object, raising MaxSizeExceeded if too large.""" 
     419     
    422420    def __init__(self, rfile, maxlen): 
    423421        self.rfile = rfile 
     
    441439            self._check_length() 
    442440            return data 
    443  
     441         
    444442        # User didn't specify a size ... 
    445443        # We read the line in chunks to make sure it's not a 100MB line ! 
     
    450448            self._check_length() 
    451449            res.append(data) 
    452             if len(data) < 256: 
     450            # See http://www.cherrypy.org/ticket/421 
     451            if len(data) < 256 or data[-1:] == "\n": 
    453452                return ''.join(res) 
    454453     
  • trunk/cherrypy/test/test_core.py

    r892 r894  
    571571        protocol = cherrypy.config.get('server.protocol_version') 
    572572        if protocol == "HTTP/1.1": 
    573             self.assertBody("(['http://127.0.0.1:8000/'], 303)"
     573            self.assertBody("(['http://127.0.0.1:%s/'], 303)" % self.PORT
    574574        else: 
    575             self.assertBody("(['http://127.0.0.1:8000/'], 302)"
     575            self.assertBody("(['http://127.0.0.1:%s/'], 302)" % self.PORT
    576576     
    577577    def testFlatten(self): 
     
    835835        self.assertHeader('Set-Cookie', 'First=Dinsdale;') 
    836836        self.assertHeader('Set-Cookie', 'Last=Piranha;') 
    837  
     837     
    838838    def testMaxRequestSize(self): 
    839839        self.getPage("/maxrequestsize/index") 
     
    847847            self.assertInBody("Request Entity Too Large") 
    848848            cherrypy.config.update({'server.max_request_header_size': 0}) 
     849             
     850            # Test for http://www.cherrypy.org/ticket/421 
     851            # (Incorrect border condition in readline of SizeCheckWrapper). 
     852            # This hangs in rev 891 and earlier. 
     853            lines256 = "x" * 248 
     854            self.getPage("/maxrequestsize/index", 
     855                         headers=[('Host', '127.0.0.1:%s' % self.PORT), 
     856                                  ('From', lines256)]) 
    849857         
    850858        # Test upload 

Hosted by WebFaction

Log in as guest/cpguest to create tickets