Skip to content
Myr

Fix stream unsetting auth (#1312)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Fix ASGITransport path escaping * Add failing test case for auth with streaming * Fix .stream setting auth=None

authored by Tom Christie · committed by GitHub · parent 257b8fa · Browse files · 2 files+19 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+19 added−2 removed

  • tests:+17 added−0 removed
  • other:+2 added−2 removed

2 files+19 added−2 removed

modified:httpx/_client.py+2 added-2 removed
232 unmodified lines
233 json: typing.Any = None,234 params: QueryParamTypes = None,235 headers: HeaderTypes = None,236 cookies: CookieTypes = None,237 auth: AuthTypes = None,237 auth: typing.Union[AuthTypes, UnsetType] = UNSET,238 allow_redirects: bool = True,239 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,240 ) -> "StreamContextManager":241 """
1543 unmodified lines
1785 self,1786 client: BaseClient,1787 request: Request,1788 *,1789 auth: AuthTypes = None,1789 auth: typing.Union[AuthTypes, UnsetType] = UNSET,1790 allow_redirects: bool = True,1791 timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,1792 close_client: bool = False,1793 ) -> None:
48 unmodified lines
modified:tests/client/test_auth.py+17 added
161 unmodified lines
162 assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}163164165@pytest.mark.asyncio166async def test_basic_auth_with_stream() -> None:167 """168 See: https://github.com/encode/httpx/pull/1312169 """170 url = "https://example.org/"171 auth = ("tomchristie", "password123")172 app = App()173174 async with httpx.AsyncClient(transport=MockTransport(app), auth=auth) as client:175 async with client.stream("GET", url) as response:176 response.read()177178 assert response.status_code == 200179 assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}180181182@pytest.mark.asyncio183async def test_basic_auth_in_url() -> None:184 url = "https://tomchristie:password123@example.org/"185 app = App()186
508 unmodified lines