Skip to content

Commit

Permalink
Revert "add back response.read() check for all operations (#2658)" (#…
Browse files Browse the repository at this point in the history
…2672)

This reverts commit 5a3bc34.
  • Loading branch information
msyyc authored Jul 2, 2024
1 parent 7de515a commit 1ab18bd
Show file tree
Hide file tree
Showing 717 changed files with 545 additions and 11,945 deletions.
8 changes: 0 additions & 8 deletions .chronus/changes/stream_reading-2024-5-25-18-18-57.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -961,12 +961,11 @@ def response_headers_and_deserialization(
def handle_error_response(self, builder: OperationType) -> List[str]:
async_await = "await " if self.async_mode else ""
retval = [f"if response.status_code not in {str(builder.success_status_codes)}:"]
retval.extend(
[
" if _stream:",
f" {async_await} response.read() # Load the body in memory and close the socket",
]
)
response_read = f" {async_await}response.read() # Load the body in memory and close the socket"
if builder.stream_value is True: # _stream is True so no need to judge it
retval.append(response_read)
elif isinstance(builder.stream_value, str): # _stream is not sure, so we need to judge it
retval.extend([" if _stream:", f" {response_read}"])
type_ignore = " # type: ignore" if _need_type_ignore(builder) else ""
retval.append(
f" map_error(status_code=response.status_code, response=response, error_map=error_map){type_ignore}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ async def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-
response = pipeline_response.http_response

if response.status_code not in [200, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -130,8 +128,6 @@ async def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -173,8 +169,6 @@ async def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
response = pipeline_response.http_response

if response.status_code not in [200, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -150,8 +148,6 @@ def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -193,8 +189,6 @@ def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ async def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-
response = pipeline_response.http_response

if response.status_code not in [200, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -130,8 +128,6 @@ async def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -173,8 +169,6 @@ async def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ def head200(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
response = pipeline_response.http_response

if response.status_code not in [200, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -150,8 +148,6 @@ def head204(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -193,8 +189,6 @@ def head404(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-return
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def _basic_polling_initial(
response = pipeline_response.http_response

if response.status_code not in [200, 204]:
if _stream:
response.read() # Load the body in memory and close the socket
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -338,8 +337,6 @@ def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ async def _basic_polling_initial(
response = pipeline_response.http_response

if response.status_code not in [200, 204]:
if _stream:
await response.read() # Load the body in memory and close the socket
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down Expand Up @@ -313,8 +312,6 @@ async def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ async def head200(self, **kwargs: Any) -> bool:
response = pipeline_response.http_response

if response.status_code not in [200, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -128,8 +126,6 @@ async def head204(self, **kwargs: Any) -> bool:
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -172,8 +168,6 @@ async def head404(self, **kwargs: Any) -> bool:
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ def head200(self, **kwargs: Any) -> bool:
response = pipeline_response.http_response

if response.status_code not in [200, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -152,8 +150,6 @@ def head204(self, **kwargs: Any) -> bool:
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -196,8 +192,6 @@ def head404(self, **kwargs: Any) -> bool:
response = pipeline_response.http_response

if response.status_code not in [204, 404]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ async def test_one( # pylint: disable=inconsistent-return-statements
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down Expand Up @@ -154,8 +152,7 @@ async def _test_lro_initial(
response = pipeline_response.http_response

if response.status_code not in [200, 204]:
if _stream:
await response.read() # Load the body in memory and close the socket
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down Expand Up @@ -304,8 +301,7 @@ async def _test_lro_and_paging_initial(
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -400,8 +396,6 @@ async def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -491,8 +485,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ async def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ def test_one( # pylint: disable=inconsistent-return-statements
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down Expand Up @@ -232,8 +230,7 @@ def _test_lro_initial(
response = pipeline_response.http_response

if response.status_code not in [200, 204]:
if _stream:
response.read() # Load the body in memory and close the socket
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down Expand Up @@ -379,8 +376,7 @@ def _test_lro_and_paging_initial(
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
response.read() # Load the body in memory and close the socket
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -475,8 +471,6 @@ def get_next(next_link=None):
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)

Expand Down Expand Up @@ -566,8 +560,6 @@ def test_different_calls( # pylint: disable=inconsistent-return-statements
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def test_two(self, **kwargs: Any) -> None: # pylint: disable=inconsistent-retur
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ async def test_one(self, id: int, message: Optional[str] = None, **kwargs: Any)
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down Expand Up @@ -147,8 +145,6 @@ async def test_different_calls( # pylint: disable=inconsistent-return-statement
response = pipeline_response.http_response

if response.status_code not in [200]:
if _stream:
await response.read() # Load the body in memory and close the socket
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = self._deserialize.failsafe_deserialize(_models.Error, pipeline_response)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
Expand Down
Loading

0 comments on commit 1ab18bd

Please sign in to comment.