Skip to content

Commit e742bc4

Browse files
committed
Cleanup
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
1 parent 49def55 commit e742bc4

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/connectrpc/_client_shared.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
def prepare_get_params(
2323
codec: Codec, request_data: bytes, headers: HTTPHeaders
2424
) -> dict[str, str]:
25-
# Insertion order is the Query-Get order from the Connect spec; urlencode
26-
# iterates dict items in insertion order, which has been guaranteed since
27-
# Python 3.7 (we require >= 3.10).
25+
# Follow order in spec: https://connectrpc.com/docs/protocol/#unary-get-request
2826
params: dict[str, str] = {"connect": f"v{CONNECT_PROTOCOL_VERSION}", "base64": "1"}
2927
if "content-encoding" in headers:
3028
params["compression"] = headers.pop("content-encoding")

test/test_client_shared.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
from connectrpc.codec import proto_binary_codec
99

1010

11-
def test_prepare_get_params_order_without_compression() -> None:
12-
params = prepare_get_params(proto_binary_codec(), b"hello", HTTPHeaders([]))
13-
assert list(params.keys()) == ["connect", "base64", "encoding", "message"]
14-
15-
16-
def test_prepare_get_params_order_with_compression() -> None:
11+
def test_prepare_get_params_order() -> None:
1712
headers = HTTPHeaders([("content-encoding", "gzip")])
1813
params = prepare_get_params(proto_binary_codec(), b"hello", headers)
1914
assert list(params.keys()) == [
@@ -24,11 +19,11 @@ def test_prepare_get_params_order_with_compression() -> None:
2419
"message",
2520
]
2621
assert "content-encoding" not in headers
27-
28-
29-
def test_prepare_get_params_urlencode_order() -> None:
30-
headers = HTTPHeaders([("content-encoding", "gzip")])
31-
params = prepare_get_params(proto_binary_codec(), b"hello", headers)
3222
query = urlencode(params)
3323
expected_prefix = "connect=v1&base64=1&compression=gzip&encoding=proto&message="
3424
assert query.startswith(expected_prefix)
25+
26+
27+
def test_prepare_get_params_order_without_compression() -> None:
28+
params = prepare_get_params(proto_binary_codec(), b"hello", HTTPHeaders([]))
29+
assert list(params.keys()) == ["connect", "base64", "encoding", "message"]

0 commit comments

Comments
 (0)