Merge ba345fb90f into b5addb64f0
This commit is contained in:
commit
5a112e0c54
@ -208,7 +208,7 @@ def encode_request(
|
||||
|
||||
if content is not None:
|
||||
return encode_content(content)
|
||||
elif files:
|
||||
elif files is not None:
|
||||
return encode_multipart_data(data or {}, files, boundary)
|
||||
elif data:
|
||||
return encode_urlencoded_data(data)
|
||||
|
||||
@ -483,7 +483,7 @@ def main(
|
||||
params=list(params),
|
||||
content=content,
|
||||
data=dict(data),
|
||||
files=files, # type: ignore
|
||||
files=files or None, # type: ignore
|
||||
json=json,
|
||||
headers=headers,
|
||||
cookies=dict(cookies),
|
||||
|
||||
@ -344,7 +344,7 @@ async def test_multipart_data_and_files_content():
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_empty_request():
|
||||
request = httpx.Request(method, url, data={}, files={})
|
||||
request = httpx.Request(method, url, data={})
|
||||
assert isinstance(request.stream, typing.Iterable)
|
||||
assert isinstance(request.stream, typing.AsyncIterable)
|
||||
|
||||
@ -516,3 +516,13 @@ def test_allow_nan_false():
|
||||
ValueError, match="Out of range float values are not JSON compliant"
|
||||
):
|
||||
httpx.Response(200, json=data_with_inf)
|
||||
|
||||
|
||||
def test_encode_request_with_data_and_empty_files():
|
||||
request = httpx.Request(
|
||||
url="https://www.example.com", method="POST", data={"key": "value"}, files={}
|
||||
)
|
||||
assert request.headers["Content-Type"].startswith("multipart/form-data; boundary=")
|
||||
request.read()
|
||||
assert b'Content-Disposition: form-data; name="key"' in request.content
|
||||
assert b"value" in request.content
|
||||
|
||||
Loading…
Reference in New Issue
Block a user