AsyncHttpResponse Class

Abstract base class for Async HTTP responses.

Use this abstract base class to create your own transport responses.

Responses implementing this ABC are returned from your async client's send_request method if you pass in an HttpRequest


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest('GET', 'http://www.example.com')
<HttpRequest [GET], url: 'http://www.example.com'>
>>> response = await client.send_request(request)
<AsyncHttpResponse: 200 OK>
Inheritance
azure.core.rest._rest_py3._HttpResponseBase
AsyncHttpResponse
AsyncHttpResponse
AsyncHttpResponse

Constructor

AsyncHttpResponse()

Methods

close
iter_bytes

Asynchronously iterates over the response's bytes. Will decompress in the process.

iter_raw

Asynchronously iterates over the response's bytes. Will not decompress in the process.

json

Returns the whole body as a json object.

raise_for_status

Raises an HttpResponseError if the response has an error status code.

If response is good, does nothing.

read

Read the response's bytes into memory.

text

Returns the response body as a string.

close

abstract async close() -> None

iter_bytes

Asynchronously iterates over the response's bytes. Will decompress in the process.

abstract async iter_bytes(**kwargs: Any) -> AsyncIterator[bytes]

Returns

Type Description

An async iterator of bytes from the response

iter_raw

Asynchronously iterates over the response's bytes. Will not decompress in the process.

abstract async iter_raw(**kwargs: Any) -> AsyncIterator[bytes]

Returns

Type Description

An async iterator of bytes from the response

json

Returns the whole body as a json object.

abstract json() -> Any

Returns

Type Description
any

The JSON deserialized response body

Exceptions

Type Description
json.decoder.JSONDecodeError
in python 2.7
if object is not JSON decodable

raise_for_status

Raises an HttpResponseError if the response has an error status code.

If response is good, does nothing.

abstract raise_for_status() -> None

Exceptions

Type Description
azure.core.HttpResponseError if the object has an error status code.

read

Read the response's bytes into memory.

abstract async read() -> bytes

Returns

Type Description

The response's bytes

text

Returns the response body as a string.

abstract text(encoding: str | None = None) -> str

Parameters

Name Description
encoding
<xref:optional>[str]

The encoding you want to decode the text with. Can also be set independently through our encoding property

default value: None

Returns

Type Description
str

The response's content decoded as a string.

Attributes

content

content_type

encoding

headers

is_closed

is_stream_consumed

reason

request

status_code

url