aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rwxr-xr-xOpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py92
1 files changed, 92 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py
new file mode 100755
index 0000000..f25ae9b
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeServer.py
@@ -0,0 +1,92 @@
1#!/usr/bin/env python
2# -*- encoding: utf-8 -*-
3#
4# Copyright (c) Contributors, http://opensimulator.org/
5# See CONTRIBUTORS.TXT for a full list of copyright holders.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:
9# * Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# * Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# * Neither the name of the OpenSim Project nor the
15# names of its contributors may be used to endorse or promote products
16# derived from this software without specific prior written permission.
17#
18# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
19# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21# DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
22# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29
30import logging
31import BaseHTTPServer
32
33# enable debug level logging
34logging.basicConfig(level = logging.DEBUG,
35 format='%(asctime)s %(levelname)s %(message)s')
36
37# subclassed HTTPRequestHandler
38class ConciergeHandler(BaseHTTPServer.BaseHTTPRequestHandler):
39 def logRequest(self):
40 logging.info('[ConciergeHandler] %(command)s request: %(host)s:%(port)d --- %(path)s',
41 dict(command = self.command,
42 host = self.client_address[0],
43 port = self.client_address[1],
44 path = self.path))
45
46 def logResponse(self, status):
47 logging.info('[ConciergeHandler] %(command)s returned %(status)d',
48 dict(command = self.command,
49 status = status))
50
51
52 def do_HEAD(self):
53 self.logRequest()
54
55 self.send_response(200)
56 self.send_header('Content-type', 'text/html')
57 self.end_headers()
58
59 self.logResponse(200)
60
61 def do_POST(self):
62 self.logRequest()
63 hdrs = {}
64 for hdr in self.headers.headers:
65 logging.debug('[ConciergeHandler] POST: header: %s', hdr.rstrip())
66
67 length = int(self.headers.getheader('Content-Length'))
68 content = self.rfile.read(length)
69 self.rfile.close()
70
71 logging.debug('[ConciergeHandler] POST: content: %s', content)
72
73 self.send_response(200)
74 self.send_header('Content-type', 'text/html')
75 self.end_headers()
76
77 self.logResponse(200)
78
79 def log_request(code, size):
80 pass
81
82if __name__ == '__main__':
83
84 httpServer = BaseHTTPServer.HTTPServer(('', 8080), ConciergeHandler)
85 logging.info('[ConciergeServer] Concierge Broker Test Server starting')
86
87 try:
88 httpServer.serve_forever()
89 except KeyboardInterrupt:
90 logging.info('[ConciergeServer] terminating')
91
92 httpServer.server_close()