-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
raise IncompleteReadError if only receive partial response (#20888)
* raise IncompleteReadError if only receive partial response * update * Update CHANGELOG.md * update * update * update * update * update * update * update * address review feedback * update * update * update * update * Update exceptions.py
- Loading branch information
1 parent
cbb395e
commit 60e11ba
Showing
9 changed files
with
161 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
sdk/core/azure-core/tests/async_tests/test_content_length_checking_async.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding: utf-8 | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE.txt in the project root for | ||
# license information. | ||
# ------------------------------------------------------------------------- | ||
from azure.core.pipeline import AsyncPipeline | ||
from azure.core.pipeline.transport import ( | ||
HttpRequest, | ||
) | ||
from azure.core import AsyncPipelineClient | ||
from azure.core.exceptions import IncompleteReadError | ||
import pytest | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_aio_transport_short_read_download_stream(port): | ||
url = "http://localhost:{}/errors/short-data".format(port) | ||
client = AsyncPipelineClient(url) | ||
with pytest.raises(IncompleteReadError): | ||
async with client: | ||
request = HttpRequest("GET", url) | ||
pipeline_response = await client._pipeline.run(request, stream=True) | ||
response = pipeline_response.http_response | ||
data = response.stream_download(client._pipeline) | ||
content = b"" | ||
async for d in data: | ||
content += d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# coding: utf-8 | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See LICENSE.txt in the project root for | ||
# license information. | ||
# ------------------------------------------------------------------------- | ||
from azure.core import PipelineClient | ||
from azure.core.pipeline import Pipeline | ||
from azure.core.pipeline.transport import ( | ||
HttpRequest, | ||
RequestsTransport, | ||
) | ||
from azure.core.exceptions import IncompleteReadError | ||
import pytest | ||
|
||
|
||
def test_sync_transport_short_read_download_stream(port): | ||
url = "http://localhost:{}/errors/short-data".format(port) | ||
client = PipelineClient(url) | ||
request = HttpRequest("GET", url) | ||
with pytest.raises(IncompleteReadError): | ||
pipeline_response = client._pipeline.run(request, stream=True) | ||
response = pipeline_response.http_response | ||
data = response.stream_download(client._pipeline) | ||
content = b"" | ||
for d in data: | ||
content += d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters