summary refs log tree commit diff
path: root/tests/server.py
diff options
context:
space:
mode:
authorAmber Brown <hawkowl@atleastfornow.net>2018-09-20 20:14:34 +1000
committerGitHub <noreply@github.com>2018-09-20 20:14:34 +1000
commit1f3f5fcf52efdf5215dc6c7cd3805b1357bf8236 (patch)
tree0ea1a5b02e4f0659e92b40ea450af96d8a6ab702 /tests/server.py
parentMerge pull request #3914 from matrix-org/erikj/remove_retry_cache (diff)
downloadsynapse-1f3f5fcf52efdf5215dc6c7cd3805b1357bf8236.tar.xz
Fix client IPs being broken on Python 3 (#3908)
Diffstat (limited to 'tests/server.py')
-rw-r--r--tests/server.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/server.py b/tests/server.py
index ccea3baa55..7bee58dff1 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -98,7 +98,7 @@ class FakeSite:
         return FakeLogger()
 
 
-def make_request(method, path, content=b"", access_token=None):
+def make_request(method, path, content=b"", access_token=None, request=SynapseRequest):
     """
     Make a web request using the given method and path, feed it the
     content, and return the Request and the Channel underneath.
@@ -120,14 +120,16 @@ def make_request(method, path, content=b"", access_token=None):
     site = FakeSite()
     channel = FakeChannel()
 
-    req = SynapseRequest(site, channel)
+    req = request(site, channel)
     req.process = lambda: b""
     req.content = BytesIO(content)
 
     if access_token:
         req.requestHeaders.addRawHeader(b"Authorization", b"Bearer " + access_token)
 
-    req.requestHeaders.addRawHeader(b"X-Forwarded-For", b"127.0.0.1")
+    if content:
+        req.requestHeaders.addRawHeader(b"Content-Type", b"application/json")
+
     req.requestReceived(method, path, b"1.1")
 
     return req, channel