summary refs log tree commit diff
path: root/tests/server.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-11-15 15:55:58 -0600
committerGitHub <noreply@github.com>2018-11-15 15:55:58 -0600
commit8b1affe7d5ca991a1924bc054dfd64ddb3d7b488 (patch)
tree3f7913fa9f4084909536d2ac0ce1d27dd33f86e5 /tests/server.py
parentAdd option to track MAU stats (but not limit people) (#3830) (diff)
downloadsynapse-8b1affe7d5ca991a1924bc054dfd64ddb3d7b488.tar.xz
Fix Content-Disposition in media repository (#4176)
Diffstat (limited to 'tests/server.py')
-rw-r--r--tests/server.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/server.py b/tests/server.py
index 7919a1f124..ceec2f2d4e 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -14,6 +14,8 @@ from twisted.internet.error import DNSLookupError
 from twisted.internet.interfaces import IReactorPluggableNameResolver
 from twisted.python.failure import Failure
 from twisted.test.proto_helpers import MemoryReactorClock
+from twisted.web.http import unquote
+from twisted.web.http_headers import Headers
 
 from synapse.http.site import SynapseRequest
 from synapse.util import Clock
@@ -50,6 +52,15 @@ class FakeChannel(object):
             raise Exception("No result yet.")
         return int(self.result["code"])
 
+    @property
+    def headers(self):
+        if not self.result:
+            raise Exception("No result yet.")
+        h = Headers()
+        for i in self.result["headers"]:
+            h.addRawHeader(*i)
+        return h
+
     def writeHeaders(self, version, code, reason, headers):
         self.result["version"] = version
         self.result["code"] = code
@@ -152,6 +163,9 @@ def make_request(
         path = b"/_matrix/client/r0/" + path
         path = path.replace(b"//", b"/")
 
+    if not path.startswith(b"/"):
+        path = b"/" + path
+
     if isinstance(content, text_type):
         content = content.encode('utf8')
 
@@ -161,6 +175,7 @@ def make_request(
     req = request(site, channel)
     req.process = lambda: b""
     req.content = BytesIO(content)
+    req.postpath = list(map(unquote, path[1:].split(b'/')))
 
     if access_token:
         req.requestHeaders.addRawHeader(