Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Edit SimpleHttpClient to reference that header keys can be passed as str or bytes #6077

Merged
merged 5 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6077.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Edit header dicts docstrings in SimpleHttpClient to note that `str` or `bytes` can be passed as header keys.
2 changes: 1 addition & 1 deletion synapse/handlers/room_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def _lookup_3pid_v2(self, id_server, id_access_token, medium, address):
)

# Authenticate with identity server given the access token from the client
headers = {"Authorization": create_id_access_token_header(id_access_token)}
headers = {b"Authorization": create_id_access_token_header(id_access_token)}

try:
lookup_results = yield self.simple_http_client.post_json_get_json(
Expand Down
12 changes: 6 additions & 6 deletions synapse/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def post_urlencoded_get_json(self, uri, args={}, headers=None):
Args:
uri (str):
args (dict[str, str|List[str]]): query params
headers (dict[str, List[str]]|None): If not None, a map from
headers (dict[str|bytes, List[str]]|None): If not None, a map from
header name to a list of values for that header

Returns:
Expand Down Expand Up @@ -371,7 +371,7 @@ def post_json_get_json(self, uri, post_json, headers=None):
Args:
uri (str):
post_json (object):
headers (dict[str, List[str]]|None): If not None, a map from
headers (dict[str|bytes, List[str]]|None): If not None, a map from
header name to a list of values for that header

Returns:
Expand Down Expand Up @@ -414,7 +414,7 @@ def get_json(self, uri, args={}, headers=None):
None.
**Note**: The value of each key is assumed to be an iterable
and *not* a string.
headers (dict[str, List[str]]|None): If not None, a map from
headers (dict[str|bytes, List[str]]|None): If not None, a map from
header name to a list of values for that header
Returns:
Deferred: Succeeds when we get *any* 2xx HTTP response, with the
Expand All @@ -438,7 +438,7 @@ def put_json(self, uri, json_body, args={}, headers=None):
None.
**Note**: The value of each key is assumed to be an iterable
and *not* a string.
headers (dict[str, List[str]]|None): If not None, a map from
headers (dict[str|bytes, List[str]]|None): If not None, a map from
header name to a list of values for that header
Returns:
Deferred: Succeeds when we get *any* 2xx HTTP response, with the
Expand Down Expand Up @@ -482,7 +482,7 @@ def get_raw(self, uri, args={}, headers=None):
None.
**Note**: The value of each key is assumed to be an iterable
and *not* a string.
headers (dict[str, List[str]]|None): If not None, a map from
headers (dict[str|bytes, List[str]]|None): If not None, a map from
header name to a list of values for that header
Returns:
Deferred: Succeeds when we get *any* 2xx HTTP response, with the
Expand Down Expand Up @@ -516,7 +516,7 @@ def get_file(self, url, output_stream, max_size=None, headers=None):
Args:
url (str): The URL to GET
output_stream (file): File to write the response body to.
headers (dict[str, List[str]]|None): If not None, a map from
headers (dict[str|bytes, List[str]]|None): If not None, a map from
header name to a list of values for that header
Returns:
A (int,dict,string,int) tuple of the file length, dict of the response
Expand Down