mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 03:04:53 -04:00
Fix client IPs being broken on Python 3 (#3908)
This commit is contained in:
parent
3fd68d533b
commit
1f3f5fcf52
9 changed files with 238 additions and 58 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue