aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rwxr-xr-xOpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py33
1 files changed, 27 insertions, 6 deletions
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 @@
29 29
30import logging 30import logging
31import BaseHTTPServer 31import BaseHTTPServer
32import optparse
32import xml.etree.ElementTree as ET 33import xml.etree.ElementTree as ET
33import xml.parsers.expat 34import xml.parsers.expat
34 35
@@ -37,6 +38,8 @@ import xml.parsers.expat
37logging.basicConfig(level = logging.DEBUG, 38logging.basicConfig(level = logging.DEBUG,
38 format='%(asctime)s %(levelname)s %(message)s') 39 format='%(asctime)s %(levelname)s %(message)s')
39 40
41options = None
42
40# subclassed HTTPRequestHandler 43# subclassed HTTPRequestHandler
41class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler): 44class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler):
42 def logRequest(self): 45 def logRequest(self):
@@ -86,21 +89,39 @@ class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler):
86 logging.error('[ConciergeHandler] POST illformed:%s', xmlError) 89 logging.error('[ConciergeHandler] POST illformed:%s', xmlError)
87 self.send_response(500) 90 self.send_response(500)
88 return 91 return
89
90 self.send_response(200)
91 self.send_header('Content-type', 'text/html')
92 self.end_headers()
93 92
94 self.logResponse(200) 93 if not options.fail:
94 self.send_response(200)
95 self.send_header('Content-Type', 'text/html')
96 self.send_header('Content-Length', len('<success/>'))
97 self.end_headers()
98 self.logResponse(200)
99 self.wfile.write('<success/>')
100 self.wfile.close()
101 else:
102 self.send_response(500)
103 self.send_header('Content-Type', 'text/html')
104 self.send_header('Content-Length', len('<error>gotcha!</error>'))
105 self.end_headers()
106 self.wfile.write('<error>gotcha!</error>')
107 self.wfile.close()
108
109 self.logResponse(500)
95 110
96 def log_request(code, size): 111 def log_request(code, size):
97 pass 112 pass
98 113
99if __name__ == '__main__': 114if __name__ == '__main__':
100 115
101 httpServer = BaseHTTPServer.HTTPServer(('', 8080), ConciergeHandler)
102 logging.info('[ConciergeServer] Concierge Broker Test Server starting') 116 logging.info('[ConciergeServer] Concierge Broker Test Server starting')
103 117
118 parser = optparse.OptionParser()
119 parser.add_option('-p', '--port', dest = 'port', help = 'port to listen on', metavar = 'PORT')
120 parser.add_option('-f', '--fail', dest = 'fail', action = 'store_true', help = 'always fail POST requests')
121
122 (options, args) = parser.parse_args()
123
124 httpServer = BaseHTTPServer.HTTPServer(('', 8080), ConciergeHandler)
104 try: 125 try:
105 httpServer.serve_forever() 126 httpServer.serve_forever()
106 except KeyboardInterrupt: 127 except KeyboardInterrupt: