Fix stream unsetting auth (#1312)
* Fix ASGITransport path escaping * Add failing test case for auth with streaming * Fix .stream setting auth=None
This commit is contained in:
parent
257b8fab6a
commit
d25f2bfeff
@ -234,7 +234,7 @@ class BaseClient:
|
||||
params: QueryParamTypes = None,
|
||||
headers: HeaderTypes = None,
|
||||
cookies: CookieTypes = None,
|
||||
auth: AuthTypes = None,
|
||||
auth: typing.Union[AuthTypes, UnsetType] = UNSET,
|
||||
allow_redirects: bool = True,
|
||||
timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,
|
||||
) -> "StreamContextManager":
|
||||
@ -1786,7 +1786,7 @@ class StreamContextManager:
|
||||
client: BaseClient,
|
||||
request: Request,
|
||||
*,
|
||||
auth: AuthTypes = None,
|
||||
auth: typing.Union[AuthTypes, UnsetType] = UNSET,
|
||||
allow_redirects: bool = True,
|
||||
timeout: typing.Union[TimeoutTypes, UnsetType] = UNSET,
|
||||
close_client: bool = False,
|
||||
|
||||
@ -162,6 +162,23 @@ async def test_basic_auth() -> None:
|
||||
assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_auth_with_stream() -> None:
|
||||
"""
|
||||
See: https://github.com/encode/httpx/pull/1312
|
||||
"""
|
||||
url = "https://example.org/"
|
||||
auth = ("tomchristie", "password123")
|
||||
app = App()
|
||||
|
||||
async with httpx.AsyncClient(transport=MockTransport(app), auth=auth) as client:
|
||||
async with client.stream("GET", url) as response:
|
||||
response.read()
|
||||
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {"auth": "Basic dG9tY2hyaXN0aWU6cGFzc3dvcmQxMjM="}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_basic_auth_in_url() -> None:
|
||||
url = "https://tomchristie:password123@example.org/"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user