--- Quixote-0.7a3/server/medusa_http.py 2004-02-16 12:04:21.000000000 -0600 +++ quixote/server/medusa_http.py 2004-02-16 11:54:54.000000000 -0600 @@ -11,8 +11,9 @@ import sys import asyncore, rfc822, socket +import string from StringIO import StringIO -from medusa import http_server, xmlrpc_handler +from medusa import http_server from quixote.http_request import HTTPRequest from quixote.http_response import Stream from quixote.publish import Publisher @@ -30,6 +31,39 @@ return '' +class Collector: + """ Gathers input for POST and PUT requests. + Copied (with a slight modification) from + medusa.xmlrpc_handler. + """ + + def __init__ (self, handler, request): + self.handler = handler + self.request = request + self.data = [] + + # make sure there's a content-length header + cl = request.get_header ('content-length') + + if not cl: + request.error (411) + else: + cl = string.atoi (cl) + # using a 'numeric' terminator + self.request.channel.set_terminator (cl) + + + def collect_incoming_data (self, data): + self.data.append(data) + + + def found_terminator (self): + # set the terminator back to the default + self.request.channel.set_terminator ('\r\n\r\n') + self.handler.continue_request ("".join(self.data), self.request) + + + class QuixoteHandler: def __init__ (self, publisher, server_name, server): """QuixoteHandler(publisher:Publisher, server_name:string, @@ -50,7 +84,7 @@ msg = rfc822.Message(StringIO('\n'.join(request.header))) length = int(msg.get('Content-Length', '0')) if length: - request.collector = xmlrpc_handler.collector(self, request) + request.collector = Collector(self, request) else: self.continue_request('', request)