Skip to content

Commit

Permalink
fix(client): handle domains with underscores (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Sep 19, 2024
1 parent c03a71f commit 84ad451
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/anthropic/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,17 @@ def _build_request(
if not files:
files = cast(HttpxRequestFiles, ForceMultipartDict())

prepared_url = self._prepare_url(options.url)
if "_" in prepared_url.host:
# work around https://github.com/encode/httpx/discussions/2880
kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}

# TODO: report this error to httpx
return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
headers=headers,
timeout=self.timeout if isinstance(options.timeout, NotGiven) else options.timeout,
method=options.method,
url=self._prepare_url(options.url),
url=prepared_url,
# the `Query` type that we use is incompatible with qs'
# `Params` type as it needs to be typed as `Mapping[str, object]`
# so that passing a `TypedDict` doesn't cause an error.
Expand Down

0 comments on commit 84ad451

Please sign in to comment.