---
title: FastlyResponse
summary: A requests.Response-compatible response object.
url: https://www.fastly.com/documentation/reference/compute/sdks/python/fastly_compute/requests/response/class.FastlyResponse/
---

**Kind:** Class  
**Module:** [response](https://www.fastly.com/documentation/reference/compute/sdks/python/fastly_compute/requests/response/)  
**Package:** fastly-compute 0.1.3  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L13

A requests.Response-compatible response object.

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

## Constructor

**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L20

```python
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

**Type:** `int`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L41

HTTP status code.

### url

**Type:** `str`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L46

Final URL that was requested.

### headers

**Type:** `dict[str, str]`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L51

Response headers as a case-insensitive dict.

### content

**Type:** `bytes`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L84

Response body as bytes.

### text

**Type:** `str`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L92

Response body as unicode string.

### ok

**Type:** `bool`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L120

True if status code is less than 400.

### is_redirect

**Type:** `bool`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L125

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

### is_permanent_redirect

**Type:** `bool`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L130

True if status code is a permanent redirect.

### reason

**Type:** `str`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L146

HTTP status reason phrase.

### encoding

**Type:** `str | None`  
**Flags:** read-only  
**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L165

Response encoding.

## Methods

### __bool__

**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L169

```python
__bool__() -> bool
```

Boolean evaluation returns ok status.

**Returns**

`bool`

### __repr__

**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L174

```python
__repr__() -> str
```

String representation of the response.

**Returns**

`str`

### json

**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L108

```python
json(**kwargs: Any) -> Any
```

Parse response body as JSON.

**Parameters**

- `**kwargs`: `Any` (optional) — Additional arguments passed to json.loads()

**Returns**

`Any`

Parsed JSON data

**Throws**

- [json.JSONDecodeError](https://docs.python.org/3/library/json.html#json.JSONDecodeError) — If response is not valid JSON

### raise_for_status

**Source:** https://github.com/fastly/compute-sdk-python/blob/2bffcc6d596a68bcc0b4342404641deff78e68f6/fastly_compute/requests/response.py#L134

```python
raise_for_status() -> None
```

Raise an HTTPError for bad responses.

**Returns**

`None`

**Throws**

- [HTTPError](https://www.fastly.com/documentation/reference/compute/sdks/python/fastly_compute/requests/exceptions/class.HTTPError/) — If response status indicates an error
