Ticket #4118: http_request.diff

File http_request.diff, 1.2 KB (added by rikyu, 7 years ago)

http.Request patch that moves request body parsing into a separate, overridable function

  • twisted/web/http.py

     
    710710        # serialized and sent with the request so CGIs will work remotely
    711711        self.client = self.channel.transport.getPeer()
    712712        self.host = self.channel.transport.getHost()
     713       
     714        self.parseRequestBody()
     715       
     716        self.process()
    713717
     718
     719    def __repr__(self):
     720        return '<%s %s %s>'% (self.method, self.uri, self.clientproto)
     721
     722    def parseRequestBody(self):
     723        """
     724        Read the request body and parse any available POST data.
     725       
     726        Can be overridden in subclasses.
     727        This method is not intended for users.
     728        """
    714729        # Argument processing
    715730        args = self.args
    716731        ctype = self.requestHeaders.getRawHeaders('content-type')
     
    738753                    raise
    739754            self.content.seek(0, 0)
    740755
    741         self.process()
    742 
    743 
    744     def __repr__(self):
    745         return '<%s %s %s>'% (self.method, self.uri, self.clientproto)
    746 
    747756    def process(self):
    748757        """Override in subclasses.
    749758