HttpResponse Class

Inheritance
azure.core.pipeline.transport._base._HttpResponseBase
HttpResponse

Constructor

HttpResponse(request: HttpRequest, internal_response: Any, block_size: int | None = None)

Parameters

Name Description
request
Required
internal_response
Required
block_size
default value: None

Methods

body

Return the whole body as bytes in memory.

Sync implementer should load the body in memory if they can. Async implementer should rely on async load_body to have been called first.

parts

Assuming the content-type is multipart/mixed, will return the parts as an iterator.

raise_for_status

Raises an HttpResponseError if the response has an error status code. If response is good, does nothing.

stream_download

Generator for streaming request body data.

Should be implemented by sub-classes if streaming download is supported.

text

Return the whole body as a string.

body

Return the whole body as bytes in memory.

Sync implementer should load the body in memory if they can. Async implementer should rely on async load_body to have been called first.

body() -> bytes

Returns

Type Description

The whole body as bytes in memory.

parts

Assuming the content-type is multipart/mixed, will return the parts as an iterator.

parts() -> Iterator[HttpResponse]

Returns

Type Description
<xref:iterator>[HttpResponse]

The iterator of HttpResponse if request was multipart/mixed

Exceptions

Type Description

If the content is not multipart/mixed

raise_for_status

Raises an HttpResponseError if the response has an error status code. If response is good, does nothing.

raise_for_status() -> None

stream_download

Generator for streaming request body data.

Should be implemented by sub-classes if streaming download is supported.

stream_download(pipeline: Pipeline[HttpRequest, 'HttpResponse'], **kwargs: Any) -> Iterator[bytes]

Parameters

Name Description
pipeline
Required

The pipeline object

Returns

Type Description
<xref:iterator>[bytes]

The generator of bytes connected to the socket

text

Return the whole body as a string.

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

Parameters

Name Description
encoding
str

The encoding to apply. If None, use "utf-8" with BOM parsing (utf-8-sig). Implementation can be smarter if they want (using headers or chardet).

default value: None

Returns

Type Description
str

The whole body as a string.

See also

~body()