Add a custom_headers param to make_request (#8760)

Some tests want to set some custom HTTP request headers, so provide a way to do
that before calling requestReceived().
This commit is contained in:
Richard van der Hoff 2020-11-16 14:45:22 +00:00 committed by GitHub
parent f1de4bb58b
commit ebc405446e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 11 deletions

View file

@ -296,10 +296,12 @@ class RestHelper:
image_length = len(image_data)
path = "/_matrix/media/r0/upload?filename=%s" % (filename,)
request, channel = make_request(
self.hs.get_reactor(), "POST", path, content=image_data, access_token=tok
)
request.requestHeaders.addRawHeader(
b"Content-Length", str(image_length).encode("UTF-8")
self.hs.get_reactor(),
"POST",
path,
content=image_data,
access_token=tok,
custom_headers=[(b"Content-Length", str(image_length))],
)
request.render(resource)
self.hs.get_reactor().pump([100])