Skip to content
Snippets Groups Projects
Commit 956272d2 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix HTTP test harness for python3

parent 808d1a73
No related branches found
No related tags found
1 merge request!35Convert viewer tree to utilize python3
......@@ -98,9 +98,9 @@ def read(self):
while size_remaining:
chunk_size = min(size_remaining, max_chunk_size)
chunk = self.rfile.read(chunk_size)
L.append(chunk)
L.append(chunk.decode('utf-8'))
size_remaining -= len(chunk)
return ''.join(L)
return (''.join(L)).encode('utf-8')
# end of swiped read() logic
def read_xml(self):
......@@ -132,7 +132,7 @@ def do_POST(self):
# self.answer(self.read())
try:
self.answer(dict(reply="success", status=200,
reason=self.read()))
reason=self.read().decode('utf-8')))
except self.ignore_exceptions as e:
print("Exception during POST (ignoring): %s" % str(e), file=sys.stderr)
......@@ -141,7 +141,7 @@ def do_PUT(self):
# self.answer(self.read())
try:
self.answer(dict(reply="success", status=200,
reason=self.read()))
reason=self.read().decode('utf-8')))
except self.ignore_exceptions as e:
print("Exception during PUT (ignoring): %s" % str(e), file=sys.stderr)
......@@ -183,7 +183,7 @@ def answer(self, data, withdata=True):
self.send_header("Content-type", "text/plain")
self.end_headers()
if body:
self.wfile.write(body)
self.wfile.write(body.encode('utf-8'))
elif "/bug2295/" in self.path:
# Test for https://jira.secondlife.com/browse/BUG-2295
#
......@@ -218,7 +218,7 @@ def answer(self, data, withdata=True):
self.send_header("Content-type", "text/plain")
self.end_headers()
if body:
self.wfile.write(body)
self.wfile.write(body.encode('utf-8'))
elif "fail" not in self.path:
data = data.copy() # we're going to modify
# Ensure there's a "reply" key in data, even if there wasn't before
......@@ -230,7 +230,7 @@ def answer(self, data, withdata=True):
self.reflect_headers()
self.send_header("Content-type", "application/llsd+xml")
self.send_header("Content-Length", str(len(response)))
self.send_header("X-LL-Special", "Mememememe");
self.send_header("X-LL-Special", "Mememememe")
self.end_headers()
if withdata:
self.wfile.write(response)
......@@ -253,8 +253,8 @@ def answer(self, data, withdata=True):
def reflect_headers(self):
for name in list(self.headers.keys()):
# print "Header: %s: %s" % (name, self.headers[name])
self.send_header("X-Reflect-" + name, self.headers[name])
# print("Header: %s: %s" % (name, self.headers[name]))
self.send_header("X-Reflect-" + name, str(self.headers[name]))
if not VERBOSE:
# When VERBOSE is set, skip both these overrides because they exist to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment