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

Changeset 1988

Show
Ignore:
Timestamp:
06/23/08 23:04:12
Author:
fumanchu
Message:

Fix for #823 (Automatic comparison of content-length and max_request_body_size).

Files:

Legend:

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

    r1971 r1988  
    547547        conn.close() 
    548548     
     549    def test_Content_Length(self): 
     550        # Try a non-chunked request where Content-Length exceeds 
     551        # server.max_request_body_size. Assert error before body send. 
     552        self.persistent = True 
     553        conn = self.HTTP_CONN 
     554        conn.putrequest("POST", "/upload", skip_host=True) 
     555        conn.putheader("Host", self.HOST) 
     556        conn.putheader("Content-Type", "text/plain") 
     557        conn.putheader("Content-Length", 9999) 
     558        conn.endheaders() 
     559        response = conn.getresponse() 
     560        self.status, self.headers, self.body = webtest.shb(response) 
     561        self.assertStatus(413) 
     562        self.assertBody("") 
     563        conn.close() 
     564     
    549565    def test_HTTP10(self): 
    550566        self.PROTOCOL = "HTTP/1.0" 
  • trunk/cherrypy/wsgiserver/__init__.py

    r1978 r1988  
    396396        except ValueError, ex: 
    397397            self.simple_response("400 Bad Request", repr(ex.args)) 
     398            return 
     399         
     400        mrbs = self.max_request_body_size 
     401        if mrbs and int(environ.get("CONTENT_LENGTH", 0)) > mrbs: 
     402            self.simple_response("413 Request Entity Too Large") 
    398403            return 
    399404         

Hosted by WebFaction

Log in as guest/cpguest to create tickets