Skip to content

Commit b5e2fd1

Browse files
authored
Merge pull request #481 from microsoft/fix/http-base-uri-initialization
fix: only use base_uri from http client
2 parents d3806ca + c312efe commit b5e2fd1

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/http/httpx/kiota_http/httpx_request_adapter.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ def __init__(
8787
if not http_client:
8888
http_client = KiotaClientFactory.create_with_default_middleware()
8989
self._http_client: httpx.AsyncClient = http_client
90-
if not base_url:
91-
base_url = str(http_client.base_url) if http_client.base_url is not None else ""
92-
self._base_url: str = base_url
90+
self._base_url: str = str(http_client.base_url) if http_client.base_url is not None else ""
9391
if not observability_options:
9492
observability_options = ObservabilityOptions()
9593
self.observability_options = observability_options

packages/http/httpx/tests/test_httpx_request_adapter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,11 @@ async def test_send_primitive_async_302_with_location_header_does_not_throw(
449449
assert "location" in resp.headers
450450
await request_adapter.send_primitive_async(request_info, "float", {})
451451

452+
def test_httpx_request_adapter_ignores_base_url_parameter(auth_provider):
453+
request_adapter = HttpxRequestAdapter(auth_provider, base_url="https://no.com")
454+
assert request_adapter.base_url == ""
452455

453456
def test_httpx_request_adapter_uses_http_client_base_url(auth_provider):
454457
http_client = httpx.AsyncClient(base_url=BASE_URL)
455-
request_adapter = HttpxRequestAdapter(auth_provider, http_client=http_client)
458+
request_adapter = HttpxRequestAdapter(auth_provider, http_client=http_client, base_url="https://no.com")
456459
assert request_adapter.base_url == BASE_URL

0 commit comments

Comments
 (0)