urls are bytes in Twisted

This commit is contained in:
meejah 2019-09-27 11:52:27 -06:00
parent 27e7e5e868
commit 2b4b8e11ce
2 changed files with 4 additions and 5 deletions

View File

@ -35,13 +35,12 @@ class RenderSlashUri(unittest.TestCase):
"""
def setUp(self):
self.request = DummyRequest("/uri")
self.request = DummyRequest(b"/uri")
self.request.fields = {}
def prepathURL():
return "http://127.0.0.1.99999/{}".format(
"/".join(self.request.prepath)
)
return b"http://127.0.0.1.99999/" + b"/".join(self.request.prepath)
self.request.prePathURL = prepathURL
self.client = Mock()
self.res = URIHandler(self.client)

View File

@ -75,7 +75,7 @@ class URIHandler(resource.Resource, object):
redir_uri = redir_uri.child(urllib.quote(uri_arg).decode('utf8'))
# add back all the query args that AREN'T "?uri="
for k, values in req.args.items():
if k != "uri":
if k != b"uri":
for v in values:
redir_uri = redir_uri.add(k.decode('utf8'), v.decode('utf8'))
return redirectTo(redir_uri.to_text().encode('utf8'), req)