67
67
read_body_with_max_size ,
68
68
)
69
69
from synapse .http .federation .matrix_federation_agent import MatrixFederationAgent
70
+ from synapse .http .types import QueryParams
70
71
from synapse .logging import opentracing
71
72
from synapse .logging .context import make_deferred_yieldable , run_in_background
72
73
from synapse .logging .opentracing import set_tag , start_active_span , tags
98
99
99
100
_next_id = 1
100
101
101
-
102
- QueryArgs = Dict [str , Union [str , List [str ]]]
103
-
104
-
105
102
T = TypeVar ("T" )
106
103
107
104
@@ -144,7 +141,7 @@ class MatrixFederationRequest:
144
141
"""A callback to generate the JSON.
145
142
"""
146
143
147
- query : Optional [dict ] = None
144
+ query : Optional [QueryParams ] = None
148
145
"""Query arguments.
149
146
"""
150
147
@@ -165,10 +162,7 @@ def __attrs_post_init__(self) -> None:
165
162
166
163
destination_bytes = self .destination .encode ("ascii" )
167
164
path_bytes = self .path .encode ("ascii" )
168
- if self .query :
169
- query_bytes = encode_query_args (self .query )
170
- else :
171
- query_bytes = b""
165
+ query_bytes = encode_query_args (self .query )
172
166
173
167
# The object is frozen so we can pre-compute this.
174
168
uri = urllib .parse .urlunparse (
@@ -485,10 +479,7 @@ async def _send_request(
485
479
method_bytes = request .method .encode ("ascii" )
486
480
destination_bytes = request .destination .encode ("ascii" )
487
481
path_bytes = request .path .encode ("ascii" )
488
- if request .query :
489
- query_bytes = encode_query_args (request .query )
490
- else :
491
- query_bytes = b""
482
+ query_bytes = encode_query_args (request .query )
492
483
493
484
scope = start_active_span (
494
485
"outgoing-federation-request" ,
@@ -746,7 +737,7 @@ async def put_json(
746
737
self ,
747
738
destination : str ,
748
739
path : str ,
749
- args : Optional [QueryArgs ] = None ,
740
+ args : Optional [QueryParams ] = None ,
750
741
data : Optional [JsonDict ] = None ,
751
742
json_data_callback : Optional [Callable [[], JsonDict ]] = None ,
752
743
long_retries : bool = False ,
@@ -764,7 +755,7 @@ async def put_json(
764
755
self ,
765
756
destination : str ,
766
757
path : str ,
767
- args : Optional [QueryArgs ] = None ,
758
+ args : Optional [QueryParams ] = None ,
768
759
data : Optional [JsonDict ] = None ,
769
760
json_data_callback : Optional [Callable [[], JsonDict ]] = None ,
770
761
long_retries : bool = False ,
@@ -781,7 +772,7 @@ async def put_json(
781
772
self ,
782
773
destination : str ,
783
774
path : str ,
784
- args : Optional [QueryArgs ] = None ,
775
+ args : Optional [QueryParams ] = None ,
785
776
data : Optional [JsonDict ] = None ,
786
777
json_data_callback : Optional [Callable [[], JsonDict ]] = None ,
787
778
long_retries : bool = False ,
@@ -891,7 +882,7 @@ async def post_json(
891
882
long_retries : bool = False ,
892
883
timeout : Optional [int ] = None ,
893
884
ignore_backoff : bool = False ,
894
- args : Optional [QueryArgs ] = None ,
885
+ args : Optional [QueryParams ] = None ,
895
886
) -> Union [JsonDict , list ]:
896
887
"""Sends the specified json data using POST
897
888
@@ -961,7 +952,7 @@ async def get_json(
961
952
self ,
962
953
destination : str ,
963
954
path : str ,
964
- args : Optional [QueryArgs ] = None ,
955
+ args : Optional [QueryParams ] = None ,
965
956
retry_on_dns_fail : bool = True ,
966
957
timeout : Optional [int ] = None ,
967
958
ignore_backoff : bool = False ,
@@ -976,7 +967,7 @@ async def get_json(
976
967
self ,
977
968
destination : str ,
978
969
path : str ,
979
- args : Optional [QueryArgs ] = ...,
970
+ args : Optional [QueryParams ] = ...,
980
971
retry_on_dns_fail : bool = ...,
981
972
timeout : Optional [int ] = ...,
982
973
ignore_backoff : bool = ...,
@@ -990,7 +981,7 @@ async def get_json(
990
981
self ,
991
982
destination : str ,
992
983
path : str ,
993
- args : Optional [QueryArgs ] = None ,
984
+ args : Optional [QueryParams ] = None ,
994
985
retry_on_dns_fail : bool = True ,
995
986
timeout : Optional [int ] = None ,
996
987
ignore_backoff : bool = False ,
@@ -1085,7 +1076,7 @@ async def delete_json(
1085
1076
long_retries : bool = False ,
1086
1077
timeout : Optional [int ] = None ,
1087
1078
ignore_backoff : bool = False ,
1088
- args : Optional [QueryArgs ] = None ,
1079
+ args : Optional [QueryParams ] = None ,
1089
1080
) -> Union [JsonDict , list ]:
1090
1081
"""Send a DELETE request to the remote expecting some json response
1091
1082
@@ -1150,7 +1141,7 @@ async def get_file(
1150
1141
destination : str ,
1151
1142
path : str ,
1152
1143
output_stream ,
1153
- args : Optional [QueryArgs ] = None ,
1144
+ args : Optional [QueryParams ] = None ,
1154
1145
retry_on_dns_fail : bool = True ,
1155
1146
max_size : Optional [int ] = None ,
1156
1147
ignore_backoff : bool = False ,
0 commit comments