Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Commit d6a80a5

Browse files
fix(client): don't send Content-Type header on GET requests
1 parent ca89c7f commit d6a80a5

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ dev = [
5353
Homepage = "https://github.com/llamastack/llama-stack-client-python"
5454
Repository = "https://github.com/llamastack/llama-stack-client-python"
5555

56-
57-
5856
[build-system]
5957
requires = ["hatchling==1.26.3", "hatch-fancy-pypi-readme"]
6058
build-backend = "hatchling.build"

src/llama_stack_client/_base_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,15 @@ def _build_request(
529529
# work around https://github.com/encode/httpx/discussions/2880
530530
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
531531

532+
is_body_allowed = options.method.lower() != "get"
533+
534+
if is_body_allowed:
535+
kwargs["json"] = json_data if is_given(json_data) else None
536+
kwargs["files"] = files
537+
else:
538+
headers.pop("Content-Type", None)
539+
kwargs.pop("data", None)
540+
532541
# TODO: report this error to httpx
533542
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
534543
headers=headers,
@@ -540,8 +549,6 @@ def _build_request(
540549
# so that passing a `TypedDict` doesn't cause an error.
541550
# https://github.com/microsoft/pyright/issues/3526#event-6715453066
542551
params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
543-
json=json_data if is_given(json_data) else None,
544-
files=files,
545552
**kwargs,
546553
)
547554

tests/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ def test_request_extra_query(self) -> None:
431431
def test_multipart_repeating_array(self, client: LlamaStackClient) -> None:
432432
request = client._build_request(
433433
FinalRequestOptions.construct(
434-
method="get",
434+
method="post",
435435
url="/foo",
436436
headers={"Content-Type": "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82"},
437437
json_data={"array": ["foo", "bar"]},
@@ -1245,7 +1245,7 @@ def test_request_extra_query(self) -> None:
12451245
def test_multipart_repeating_array(self, async_client: AsyncLlamaStackClient) -> None:
12461246
request = async_client._build_request(
12471247
FinalRequestOptions.construct(
1248-
method="get",
1248+
method="post",
12491249
url="/foo",
12501250
headers={"Content-Type": "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82"},
12511251
json_data={"array": ["foo", "bar"]},

0 commit comments

Comments
 (0)