---
title: CandidateResponse
summary: A response from a backend that is a candidate for caching.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/
---

**Kind:** Struct  
**Module:** [http](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#125

```rust
pub struct CandidateResponse { /* private fields */ }
```

A response from a backend that is a candidate for caching.

## Methods

### append_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#564

```rust
fn append_header(&mut self, name: impl ToHeaderName, value: impl ToHeaderValue)
```

Add a response header with given value.

Unlike [`set_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_header), this does not discard existing values for the
same header name.

#### Argument type conversion

The header name and value arguments can be any types that implement [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/) and
[`ToHeaderValue`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderValue/), respectively. See those traits for details on which types can be used and when
panics may arise during conversion.

#### Examples

See [`Response::append_header`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-append_header).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`

### append_vary

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#767

```rust
fn append_vary<'a>(&mut self, headers: impl IntoIterator<Item = &'a HeaderName>)
```

Adds zero or more headers to the set of request headers for which the response may vary.

**Parameters**

- `self`: `&mut Self`
- `headers`: `impl IntoIterator<Item = &'a HeaderName>`

### contains_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#407

```rust
fn contains_header(&self, name: impl ToHeaderName) -> bool
```

Returns whether the given header name is present in the response.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::contains_header`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-contains_header).

**Parameters**

- `self`: `&Self`
- `name`: `impl ToHeaderName`

**Returns**

`bool`

### get_age

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#683

```rust
fn get_age(&self) -> Duration
```

The current age of the cached item, relative to the originating backend.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### get_content_length

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#394

```rust
fn get_content_length(&self) -> Option<usize>
```

Get the value of the response's
[`Content-Length`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length)
header, if it exists.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<usize>`

### get_content_type

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#368

```rust
fn get_content_type(&self) -> Option<Mime>
```

Get the MIME type described by the response's
[`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type)
header, or `None` if that header is absent or contains an invalid MIME type.

#### Examples

See [`Response::get_content_type`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_content_type).

**Parameters**

- `self`: `&Self`

**Returns**

`Option<Mime>`

### get_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#471

```rust
fn get_header(&self, name: impl ToHeaderName) -> Option<&HeaderValue>
```

Get the value of a header, or `None` if the header is not present.

If there are multiple values for the header, only one is returned, which may be any of the
values. See [`get_header_all()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all) if you need to get all of the
values.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::get_header`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header).

**Parameters**

- `self`: `&Self`
- `name`: `impl ToHeaderName`

**Returns**

`Option<&HeaderValue>`

### get_header_all

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#519

```rust
fn get_header_all(&self, name: impl ToHeaderName) -> impl Iterator<Item = &HeaderValue>
```

Get an iterator of all the values of a header.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::get_header_all`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header_all).

**Parameters**

- `self`: `&Self`
- `name`: `impl ToHeaderName`

**Returns**

`impl Iterator<Item = &HeaderValue>`

### get_header_all_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#486

```rust
fn get_header_all_str(&self, name: impl ToHeaderName) -> Vec<&str>
```

Get all values of a header as strings, or an empty vector if the header is not present.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Panics

This method panics if any of the header values are not valid UTF-8 strings. To handle the
possibility of non-UTF-8 data, use
[`get_header_all_str_lossy()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all_str_lossy) for lossy conversion, or use
[`get_header_all()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all) and then convert the bytes with
[`std::str::from_utf8()`](https://doc.rust-lang.org/stable/core/str/converts/fn.from_utf8.html).

#### Examples

See [`Response::get_header_all_str`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header_all_str).

**Parameters**

- `self`: `&Self`
- `name`: `impl ToHeaderName`

**Returns**

`Vec<&str>`

### get_header_all_str_lossy

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#508

```rust
fn get_header_all_str_lossy(&self, name: impl ToHeaderName) -> Vec<Cow<'_, str>>
```

Get all values of a header as strings, including invalid characters, or an empty vector if the header is not present.

Only the valid UTF-8 characters present are returned.
Invalid UTF-8 characters are replaced with `U+FFFD REPLACEMENT CHARACTER`.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::get_header_all_str_lossy`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header_all_str_lossy).

**Parameters**

- `self`: `&Self`
- `name`: `impl ToHeaderName`

**Returns**

`Vec<Cow<str>>`

### get_header_names

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#538

```rust
fn get_header_names(&self) -> impl Iterator<Item = &HeaderName>
```

Get an iterator of all the response's header names.

#### Examples

See [`Response::get_header_names`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header_names).

**Parameters**

- `self`: `&Self`

**Returns**

`impl Iterator<Item = &HeaderName>`

### get_header_names_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#529

```rust
fn get_header_names_str(&self) -> Vec<&str>
```

Get all of the response's header names as strings, or an empty vector if no headers are
present.

#### Examples

See [`Response::get_header_names_str`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header_names_str).

**Parameters**

- `self`: `&Self`

**Returns**

`Vec<&str>`

### get_header_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#438

```rust
fn get_header_str(&self, name: impl ToHeaderName) -> Option<&str>
```

Get the value of a header as a string, or `None` if the header is not present.

If there are multiple values for the header, only one is returned, which may be any of the
values. See [`get_header_all_str()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all_str) if you need to get all of
the values.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Panics

This method panics if the value of the header is not a valid UTF-8 string. To handle the possibility
of invalid UTF-8 data, use [`get_header_str_lossy()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_str_lossy) for lossy
conversion, or use [`get_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header) and then convert the bytes with
[`std::str::from_utf8()`](https://doc.rust-lang.org/stable/core/str/converts/fn.from_utf8.html).

#### Examples

See [`Response::get_header_str`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header_str).

**Parameters**

- `self`: `&Self`
- `name`: `impl ToHeaderName`

**Returns**

`Option<&str>`

### get_header_str_lossy

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#456

```rust
fn get_header_str_lossy(&self, name: impl ToHeaderName) -> Option<Cow<'_, str>>
```

Get the value of a header as a string, including invalid characters, or `None` if the header
is not present.

Only the valid UTF-8 characters present are returned.
Invalid UTF-8 characters are replaced with `U+FFFD REPLACEMENT CHARACTER`.

If there are multiple values for the header, only one is returned, which may be any of the
values. See [`get_header_all_str_lossy()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all_str_lossy) if you need
to get all of the values.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::get_header_str_lossy`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_header_str_lossy).

**Parameters**

- `self`: `&Self`
- `name`: `impl ToHeaderName`

**Returns**

`Option<Cow<str>>`

### get_headers

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#495

```rust
fn get_headers(&self) -> impl Iterator<Item = (&HeaderName, &HeaderValue)>
```

Get an iterator of all the response's header names and values.

#### Examples

See [`Response::get_headers`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-get_headers).

**Parameters**

- `self`: `&Self`

**Returns**

`impl Iterator<Item = (&HeaderName, &HeaderValue)>`

### get_stale_if_error

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#706

```rust
fn get_stale_if_error(&self) -> Duration
```

Gets the time for which a cached item can safely be used if (synchronous) revalidation
produces an error.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### get_stale_while_revalidate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#688

```rust
fn get_stale_while_revalidate(&self) -> Duration
```

Gets the time for which a cached item can safely be used despite being considered stale.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### get_status

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#619

```rust
fn get_status(&self) -> StatusCode
```

Get the HTTP status code of the response.

**Parameters**

- `self`: `&Self`

**Returns**

`StatusCode`

### get_surrogate_keys

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#782

```rust
fn get_surrogate_keys(&self) -> impl Iterator<Item = &str>
```

Gets the surrogate keys for the cached response.

**Parameters**

- `self`: `&Self`

**Returns**

`impl Iterator<Item = &str>`

### get_ttl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#660

```rust
fn get_ttl(&self) -> Duration
```

Get the Time to Live (TTL) in the cache for this response.

The TTL determines the duration of "freshness" for the cached response
after it is inserted into the cache.

**Parameters**

- `self`: `&Self`

**Returns**

`Duration`

### get_vary

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#746

```rust
fn get_vary(&self) -> impl Iterator<Item = &str>
```

Gets the set of request headers for which the response may vary.

**Parameters**

- `self`: `&Self`

**Returns**

`impl Iterator<Item = &str>`

### get_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#641

```rust
fn get_version(&self) -> Version
```

Get the HTTP version of this response.

**Parameters**

- `self`: `&Self`

**Returns**

`Version`

### is_cacheable

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#837

```rust
fn is_cacheable(&self) -> bool
```

Gets whether this response should be cached.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### is_sensitive_data

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#812

```rust
fn is_sensitive_data(&self) -> bool
```

Gets whether this response should only be stored via PCI/HIPAA-compliant non-volatile caching.

See the [Fastly PCI-Compliant Caching and Delivery
documentation](https://docs.fastly.com/products/pci-compliant-caching-and-delivery) for
details.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### is_stale

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#723

```rust
fn is_stale(&self) -> bool
```

Determines whether the cached response is stale.

A cached response is stale if it has been in the cache beyond its TTL period,
or if it has been [soft purged](https://www.fastly.com/documentation/guides/concepts/edge-state/cache/purging/#soft-vs-hard-purging).

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### push_vary

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#777

```rust
fn push_vary(&mut self, header: &HeaderName)
```

Adds a header to the set of request headers for which the response may vary.

**Parameters**

- `self`: `&mut Self`
- `header`: `&HeaderName`

### remove_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#580

```rust
fn remove_header(&mut self, name: impl ToHeaderName) -> Option<HeaderValue>
```

Remove all response headers of the given name, and return one of the removed header values
if any were present.

If the header has multiple values, one is returned arbitrarily. To get all of the removed
header values, or to get a specific value, use
[`get_header_all()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all).

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::remove_header`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-remove_header).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`

**Returns**

`Option<HeaderValue>`

### remove_header_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#598

```rust
fn remove_header_str(&mut self, name: impl ToHeaderName) -> Option<String>
```

Remove all response headers of the given name, and return one of the removed header values
as a string if any were present.

If the header has multiple values, one is returned arbitrarily. To get all of the removed header
values, use [`get_header_all()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all) before removing.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Panics

This method panics if the value of the header is not a valid UTF-8 string. To handle the possibility
of invalid UTF-8 data, use [`remove_header_str_lossy()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-remove_header_str_lossy) for lossy
conversion, or use [`remove_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-remove_header) and then convert the bytes with
[`std::str::from_utf8()`](https://doc.rust-lang.org/stable/core/str/converts/fn.from_utf8.html).

#### Examples

See [`Response::remove_header_str`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-remove_header_str).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`

**Returns**

`Option<String>`

### remove_header_str_lossy

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#614

```rust
fn remove_header_str_lossy(&mut self, name: impl ToHeaderName) -> Option<String>
```

Remove all response headers of the given name, and return one of the removed header values
as a string, including invalid characters, if any were present.

Only the valid UTF-8 characters present are returned.
Invalid UTF-8 characters are replaced with `U+FFFD REPLACEMENT CHARACTER`.

If the header has multiple values, one is returned arbitrarily. To get all of the removed header
values, use [`get_header_all()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-get_header_all) before removing.

#### Argument type conversion

The header name argument can be any type that implements [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::remove_header_str_lossy`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-remove_header_str_lossy).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`

**Returns**

`Option<String>`

### set_body_transform

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#907

```rust
fn set_body_transform(&mut self, transform: impl FnOnce(Body, &mut StreamingBody) -> Result<(), SendErrorCause> + 'static)
```

Sets a callback to be used for transforming the response body prior to
caching.

Body transformations are performed via a callback, rather than by
directly working with the body, because not every response contains a
fresh body: 304 Not Modified responses, which are used to revalidate a
stale cached response, are valuable precisely because they do not
retransmit the body.

For any other response status, the backend response will contain a
relevant body, and the `transform` callback will be invoked. The
original backend body of type `Body` is given as the first parameter to
the transform. The transform is responsible for writing the new body
into the `StreamingBody` given as its second argument. Upon returning from
the transform, [`StreamingBody::finish()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.StreamingBody/#method-finish) will be called implicitly. This
setup allows the transform to work with streamed chunks of the backend body,
rather than necessarily reading it entirely into memory.

**Parameters**

- `self`: `&mut Self`
- `transform`: `impl FnOnce(Body, &mut StreamingBody) -> Result<(), SendErrorCause> + 'static`

### set_cacheable

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#860

```rust
fn set_cacheable(&mut self)
```

Forces this response to be stored in the cache, even if its headers or
status would normally prevent that.

**Parameters**

- `self`: `&mut Self`

### set_content_type

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#387

```rust
fn set_content_type(&mut self, mime: Mime)
```

Set the MIME type described by the response's
[`Content-Type`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type)
header.

Any existing `Content-Type` header values will be overwritten.

#### Examples

See [`Response::set_content_type`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-set_content_type).

**Parameters**

- `self`: `&mut Self`
- `mime`: `Mime`

### set_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#550

```rust
fn set_header(&mut self, name: impl ToHeaderName, value: impl ToHeaderValue)
```

Set a response header to the given value, discarding any previous values for the given
header name.

#### Argument type conversion

The header name and value arguments can be any types that implement [`ToHeaderName`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderName/) and
[`ToHeaderValue`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToHeaderValue/), respectively. See those traits for details on which types can be used and when
panics may arise during conversion.

#### Examples

See [`Response::set_header`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-set_header).

**Parameters**

- `self`: `&mut Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`

### set_sensitive_data

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#832

```rust
fn set_sensitive_data(&mut self, is_sensitive_data: bool)
```

Set the caching behavior of this response to enable or disable PCI/HIPAA-compliant
non-volatile caching.

By default, this is `false`, which means the response may not be PCI/HIPAA-compliant. Set it
to `true` to enable compliant caching.

See the [Fastly PCI-Compliant Caching and Delivery
documentation](https://docs.fastly.com/products/pci-compliant-caching-and-delivery) for
details.

**Parameters**

- `self`: `&mut Self`
- `is_sensitive_data`: `bool`

### set_stale_if_error

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#713

```rust
fn set_stale_if_error(&mut self, stale_if_error: Duration)
```

Sets the time for which a cached item can safely be used if (synchronous) revalidation
produces an error.

**Parameters**

- `self`: `&mut Self`
- `stale_if_error`: `Duration`

### set_stale_while_revalidate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#700

```rust
fn set_stale_while_revalidate(&mut self, stale_while_revalidate: Duration)
```

Sets the time for which a cached item can safely be used despite being considered stale.

**Parameters**

- `self`: `&mut Self`
- `stale_while_revalidate`: `Duration`

### set_status

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#636

```rust
fn set_status(&mut self, status: impl ToStatusCode)
```

Set the HTTP status code of the response.

#### Argument type conversion

The status code argument can be any type that implements [`ToStatusCode`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/convert/trait.ToStatusCode/); see that trait for
details on which types can be used and when panics may arise during conversion.

#### Examples

See [`Response::set_status`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-set_status).

**Parameters**

- `self`: `&mut Self`
- `status`: `impl ToStatusCode`

### set_surrogate_keys

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#802

```rust
fn set_surrogate_keys<'a>(&mut self, keys: impl IntoIterator<Item = &'a str>)
```

Sets the surrogate keys for the cached response.

Surrogate keys must contain only printable ASCII characters (those between `0x21` and
`0x7E`, inclusive). Any invalid keys will be ignored.

See the [Fastly surrogate keys
guide](https://docs.fastly.com/en/guides/purging-api-cache-with-surrogate-keys) for details.

**Parameters**

- `self`: `&mut Self`
- `keys`: `impl IntoIterator<Item = &'a str>`

### set_ttl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#678

```rust
fn set_ttl(&mut self, ttl: Duration)
```

Set the Time to Live (TTL) in the cache for this response.

The TTL determines the duration of "freshness" for the cached response
after it is inserted into the cache.

**Parameters**

- `self`: `&mut Self`
- `ttl`: `Duration`

### set_uncacheable

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#882

```rust
fn set_uncacheable(&mut self, record_uncacheable: bool)
```

Set the response to not be stored in the cache.

Optionally, if `record_uncacheable` is true, the cache will record that
the originating request led to an uncacheable response, so that future
cache lookups will result in immediately going to the backend, rather
than attempting to coordinate concurrent requests to reduce backend
traffic.

See the [Fastly request collapsing
guide](https://www.fastly.com/documentation/guides/concepts/edge-state/cache/request-collapsing/)
for more details on the mechanism that `record_uncacheable` disables.

**Parameters**

- `self`: `&mut Self`
- `record_uncacheable`: `bool`

### set_vary

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#760

```rust
fn set_vary<'a>(&mut self, headers: impl IntoIterator<Item = &'a HeaderName>)
```

Sets the set of request headers for which the response may vary.

**Parameters**

- `self`: `&mut Self`
- `headers`: `impl IntoIterator<Item = &'a HeaderName>`

### set_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#652

```rust
fn set_version(&mut self, version: Version)
```

Set the HTTP version of this response.

**Parameters**

- `self`: `&mut Self`
- `version`: `Version`

### stale_if_error_available

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#739

```rust
fn stale_if_error_available(&self) -> bool
```

Returns true if there is a stale-if-error response available from the cache.

A CandidateResponse represents an HTTP response returned from a Backend. However, it may be
preferable to return a cached response rather than the Backend's response -- for instance,
if the Backend's response is a 5xx error.

This method returns true if there is a cached response that is within the stale-if-error
period. If a stale-if-error response is available, and the after_send hook returns an
error, the response from the Backend will not be cached, and the [Request::send](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-send) call will
return the stale-if-error response.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### with_cacheable

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#849

```rust
fn with_cacheable(self, is_cacheable: bool, record_uncacheable: bool) -> Self
```

Builder-style equivalent of [`set_cacheable()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_cacheable)
and [`set_uncacheable()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_uncacheable)

**Parameters**

- `self`: `Self`
- `is_cacheable`: `bool`
- `record_uncacheable`: `bool`

**Returns**

`Self`

### with_content_type

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#373

```rust
fn with_content_type(self, mime: Mime) -> Self
```

Builder-style equivalent of [`set_content_type()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_content_type).

**Parameters**

- `self`: `Self`
- `mime`: `Mime`

**Returns**

`Self`

### with_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#412

```rust
fn with_header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self
```

Builder-style equivalent of [`append_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-append_header).

**Parameters**

- `self`: `Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`

**Returns**

`Self`

### with_sensitive_data

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#818

```rust
fn with_sensitive_data(self, is_sensitive_data: bool) -> Self
```

Builder-style equivalent of [`set_sensitive_data()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_sensitive_data).

**Parameters**

- `self`: `Self`
- `is_sensitive_data`: `bool`

**Returns**

`Self`

### with_set_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#418

```rust
fn with_set_header(self, name: impl ToHeaderName, value: impl ToHeaderValue) -> Self
```

Builder-style equivalent of [`set_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_header).

**Parameters**

- `self`: `Self`
- `name`: `impl ToHeaderName`
- `value`: `impl ToHeaderValue`

**Returns**

`Self`

### with_stale_while_revalidate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#694

```rust
fn with_stale_while_revalidate(self, stale_while_revalidate: Duration) -> Self
```

Builder-style equivalent of [`set_stale_while_revalidate()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_stale_while_revalidate).

**Parameters**

- `self`: `Self`
- `stale_while_revalidate`: `Duration`

**Returns**

`Self`

### with_status

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#624

```rust
fn with_status(self, status: impl ToStatusCode) -> Self
```

Builder-style equivalent of [`set_status()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_status).

**Parameters**

- `self`: `Self`
- `status`: `impl ToStatusCode`

**Returns**

`Self`

### with_surrogate_keys

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#790

```rust
fn with_surrogate_keys<'a>(self, keys: impl IntoIterator<Item = &'a str>) -> Self
```

Builder-style equivalent of [`set_surrogate_keys()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_surrogate_keys).

**Parameters**

- `self`: `Self`
- `keys`: `impl IntoIterator<Item = &'a str>`

**Returns**

`Self`

### with_ttl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#669

```rust
fn with_ttl(self, ttl: Duration) -> Self
```

Builder-style equivalent of [`set_ttl()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_ttl).

**Parameters**

- `self`: `Self`
- `ttl`: `Duration`

**Returns**

`Self`

### with_vary

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#754

```rust
fn with_vary<'a>(self, headers: impl IntoIterator<Item = &'a HeaderName>) -> Self
```

Builder-style equivalent of [`set_vary()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_vary).

**Parameters**

- `self`: `Self`
- `headers`: `impl IntoIterator<Item = &'a HeaderName>`

**Returns**

`Self`

### with_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/candidate_response.rs#646

```rust
fn with_version(self, version: Version) -> Self
```

Builder-style equivalent of [`set_version()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/#method-set_version).

**Parameters**

- `self`: `Self`
- `version`: `Version`

**Returns**

`Self`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `Downcast`
- `ErasedDestructor`
- `From<T>`
- `Into<U>`
- `IntoEither`
- `Same`
- `TryFrom<U>`
- `TryInto<U>`
