FastlyResponse

Classin responsefastly-compute 0.1.3View source

A requests.Response-compatible response object.

This class wraps WIT response objects to provide the familiar requests.Response interface.

Constructor

FastlyResponse(wit_response: http_resp.Response, response_body: async_io.Pollable, url: str)

Initialize FastlyResponse.

Parameters

wit_response: http_resp.Response

The WIT response object

response_body: async_io.Pollable

The WIT response body

url: str

The final URL that was requested

Properties

status_code

intread-onlyView source

HTTP status code.

url

strread-onlyView source

Final URL that was requested.

headers

dict[str, str]read-onlyView source

Response headers as a case-insensitive dict.

content

bytesread-onlyView source

Response body as bytes.

text

strread-onlyView source

Response body as unicode string.

ok

boolread-onlyView source

True if status code is less than 400.

is_redirect

boolread-onlyView source

True if status code is a redirect (3xx).

is_permanent_redirect

boolread-onlyView source

True if status code is a permanent redirect.

reason

strread-onlyView source

HTTP status reason phrase.

encoding

str | Noneread-onlyView source

Response encoding.

Methods

__bool__

View source
__bool__() -> bool

Boolean evaluation returns ok status.

Returns

bool

__repr__

View source
__repr__() -> str

String representation of the response.

Returns

str
json(**kwargs: Any) -> Any

Parse response body as JSON.

Parameters

**kwargs: Anyoptional

Additional arguments passed to json.loads()

Returns

Any

Parsed JSON data

Throws

raise_for_status

View source
raise_for_status() -> None

Raise an HTTPError for bad responses.

Returns

None

Throws

  • HTTPError — If response status indicates an error