From 587b079878bbc2b9c0f374b0d0c75526627125bc Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Fri, 30 Jan 2009 08:49:00 +0000 Subject: --- .../Modules/Avatar/Concierge/ConciergeServer.py | 33 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py index 4a1a2b0..1c088fb 100755 --- a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py +++ b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py @@ -29,6 +29,7 @@ import logging import BaseHTTPServer +import optparse import xml.etree.ElementTree as ET import xml.parsers.expat @@ -37,6 +38,8 @@ import xml.parsers.expat logging.basicConfig(level = logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') +options = None + # subclassed HTTPRequestHandler class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler): def logRequest(self): @@ -86,21 +89,39 @@ class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler): logging.error('[ConciergeHandler] POST illformed:%s', xmlError) self.send_response(500) return - - self.send_response(200) - self.send_header('Content-type', 'text/html') - self.end_headers() - self.logResponse(200) + if not options.fail: + self.send_response(200) + self.send_header('Content-Type', 'text/html') + self.send_header('Content-Length', len('')) + self.end_headers() + self.logResponse(200) + self.wfile.write('') + self.wfile.close() + else: + self.send_response(500) + self.send_header('Content-Type', 'text/html') + self.send_header('Content-Length', len('gotcha!')) + self.end_headers() + self.wfile.write('gotcha!') + self.wfile.close() + + self.logResponse(500) def log_request(code, size): pass if __name__ == '__main__': - httpServer = BaseHTTPServer.HTTPServer(('', 8080), ConciergeHandler) logging.info('[ConciergeServer] Concierge Broker Test Server starting') + parser = optparse.OptionParser() + parser.add_option('-p', '--port', dest = 'port', help = 'port to listen on', metavar = 'PORT') + parser.add_option('-f', '--fail', dest = 'fail', action = 'store_true', help = 'always fail POST requests') + + (options, args) = parser.parse_args() + + httpServer = BaseHTTPServer.HTTPServer(('', 8080), ConciergeHandler) try: httpServer.serve_forever() except KeyboardInterrupt: -- cgit v1.1