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

Changeset 1616

Show
Ignore:
Timestamp:
02/08/07 12:25:52
Author:
fumanchu
Message:

Fix for #650 (PUT request with empty body/params ignored).

Files:

Legend:

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

    r1614 r1616  
    630630    def process_body(self): 
    631631        """Convert request.rfile into request.params (or request.body). (Core)""" 
     632        if not self.headers.get("Content-Length", ""): 
     633            # No Content-Length header supplied (or it's 0). 
     634            # If we went ahead and called cgi.FieldStorage, it would hang, 
     635            # since it cannot determine when to stop reading from the socket. 
     636            # See http://www.cherrypy.org/ticket/493. 
     637            # See also http://www.cherrypy.org/ticket/650. 
     638            # Note also that we expect any HTTP server to have decoded 
     639            # any message-body that had a transfer-coding, and we expect 
     640            # the HTTP server to have supplied a Content-Length header 
     641            # which is valid for the decoded entity-body. 
     642            return 
     643         
    632644        # FieldStorage only recognizes POST, so fake it. 
    633645        methenv = {'REQUEST_METHOD': "POST"} 
     
    816828            self.timed_out = True 
    817829 
     830 
  • trunk/cherrypy/wsgiserver/__init__.py

    r1615 r1616  
    267267        if read_chunked: 
    268268            if not self.decode_chunked(): 
    269                 return 
    270         else: 
    271             cl = environ.get("CONTENT_LENGTH") 
    272             if method in ("POST", "PUT") and cl is None: 
    273                 # No Content-Length header supplied. This will hang 
    274                 # cgi.FieldStorage, since it cannot determine when to 
    275                 # stop reading from the socket. 
    276                 # See http://www.cherrypy.org/ticket/493. 
    277                 self.simple_response("411 Length Required") 
    278269                return 
    279270         
     
    1006997                    self.ssl_environ[wsgikey] = value 
    1007998 
     999 

Hosted by WebFaction

Log in as guest/cpguest to create tickets