Skip to content

Commit 9c63a5c

Browse files
committed
Fix compatibility with urllib3-future
`grafana-client` uses the `niquests` package, which pulls in `urllib3-future` instead of vanilla `urllib3`. There was a subtle incompatibility that prevented to use `crate` and `grafana-client` within the same program.
1 parent 046a8dc commit 9c63a5c

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Unreleased
1212

1313
- Parse path prefixes from server URLs and propagate them to all requests.
1414

15+
- Fixed compatibility with ``urllib3-future``.
16+
1517
2025/01/30 2.0.0
1618
================
1719

src/crate/client/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def request(
187187
if "Content-Length" not in headers:
188188
length = super_len(data)
189189
if length is not None:
190-
headers["Content-Length"] = length
190+
headers["Content-Length"] = str(length)
191191

192192
# Authentication credentials
193193
if username is not None:

tests/client/test_http.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ def test_redirect_handling():
192192
# - https://github.com/crate/crate-python/issues/179
193193
# - https://github.com/crate/crate-python/issues/180
194194

195-
assert client.server_pool["http://localhost:4201"].pool.conn_kw == {
195+
# Remove some optional server pool parameters added by `urllib3-future`.
196+
conn_kw = client.server_pool["http://localhost:4201"].pool.conn_kw
197+
conn_kw.pop("keepalive_delay", None)
198+
conn_kw.pop("resolver", None)
199+
200+
assert conn_kw == {
196201
"socket_options": _get_socket_opts(keepalive=True)
197202
}
198203

0 commit comments

Comments
 (0)