---
title: Request
summary: An HTTP request, including body, headers, method, and URL.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/
---

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

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

An HTTP request, including body, headers, method, and URL.

## Getting the client request

Call [`Request::from_client()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-from_client) to get the client request being handled by this execution of the
Compute program.

## Creation and conversion

New requests can be created programmatically with [`Request::new()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-new). In addition, there are
convenience constructors like [`Request::get()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get) which automatically select the appropriate
method.

For interoperability with other Rust libraries, [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) can be converted to and from the
[`http`](https://docs.rs/http/latest/http/index.html) crate's [`http::Request`](https://docs.rs/http/latest/http/request/struct.Request.html) type using the [`From`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#impl-From-Request-Body) and
[`Into`](https://doc.rust-lang.org/stable/core/convert/Into/fn.into.html) traits.

## Sending backend requests

Requests can be sent to a backend in blocking or asynchronous fashion using
[`send()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-send), [`send_async()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-send_async), or
[`send_async_streaming()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-send_async_streaming).

## Builder-style methods

[`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) can be used as a
[builder](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html), allowing requests to
be constructed and used through method chaining. Methods with the `with_` name prefix, such as
[`with_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-with_header), return `Self` to allow chaining. The builder style is
typically most useful when constructing and using a request in a single expression. For example:

```rust
Request::get("https://example.com")
    .with_header("my-header", "hello!")
    .with_header("my-other-header", "Здравствуйте!")
    .send("example_backend")?;
```

## Setter methods

Setter methods, such as [`set_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_header), are prefixed by `set_`, and can
be used interchangeably with the builder-style methods, allowing you to mix and match styles
based on what is most convenient for your program. Setter methods tend to work better than
builder-style methods when constructing a request involves conditional branches or loops. For
example:

```rust
let mut req = Request::get("https://example.com").with_header("my-header", "hello!");
if needs_translation {
    req.set_header("my-other-header", "Здравствуйте!");
}
req.send("example_backend")?;
```

## Methods

### append_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1087

```rust
fn append_body(&mut self, other: Body)
```

Append another [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/) to the body of this request without reading or writing any body
contents.

If this request does not have a body, the appended body is set as the request's body.

This operation is performed in amortized constant time, and so should always be preferred to reading
an entire body and then writing the same contents to another body.

This method should be used when combining bodies that have not necessarily been read yet,
such as the body of the client. To append contents that are already in memory as strings or
bytes, you should instead use [`get_body_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_body_mut) to write the
contents to the end of the body.

#### Examples

```rust
let mut req = Request::post("https://example.com").with_body("hello! client says: ");
req.append_body(Request::from_client().into_body());
req.send("example_backend")?;
```

**Parameters**

- `self`: `&mut Self`
- `other`: `Body`

### append_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1971

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

Add a request header with given value.

Unlike [`set_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#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

```rust
let mut req = Request::get("https://example.com");

req.set_header("hello", "world!");
assert_eq!(req.get_header_str("hello"), Some("world!"));

req.append_header("hello", "universe!");

let values = req.get_header_all_str("hello");
assert_eq!(values.len(), 2);
assert!(values.contains(&"world!"));
assert!(values.contains(&"universe!"));
```

**Parameters**

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

### as_handles

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2846

```rust
fn as_handles(&self) -> (&RequestHandle, Option<&BodyHandle>)
```

Borrow the low-level [`handle` API](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/).

**Parameters**

- `self`: `&Self`

**Returns**

`(&RequestHandle, Option<&BodyHandle>)`

### clone_with_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#429

```rust
fn clone_with_body(&mut self) -> Request
```

Clone this request by reading in its body, and then writing the same body to the original
and the cloned request.

This method requires mutable access to this request because reading from and writing to the
body can involve an HTTP connection.

This operation is potentially expensive if the body is large. Take care when using this
method on bodies with unknown sizes. Consider using methods like [`BufRead::lines()`](https://doc.rust-lang.org/stable/alloc/io/buf_read/BufRead/fn.lines.html) or
[`Body::read_chunks()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/#method-read_chunks) to incrementally process a body while limiting the maximum size.

#### Examples

```rust
let mut original = Request::post("https://example.com")
    .with_header("hello", "world!")
    .with_body("hello");
let mut new = original.clone_with_body();
assert_eq!(original.get_method(), new.get_method());
assert_eq!(original.get_url(), new.get_url());
assert_eq!(original.get_header("hello"), new.get_header("hello"));
assert_eq!(original.get_version(), new.get_version());
assert_eq!(original.take_body_bytes(), new.take_body_bytes());
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`Request`

### clone_without_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#399

```rust
fn clone_without_body(&self) -> Request
```

Make a new request with the same method, url, headers, and version of this request, but no
body.

If you also need to clone the request body, use
[`clone_with_body()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-clone_with_body)

#### Examples

```rust
let original = Request::post("https://example.com")
    .with_header("hello", "world!")
    .with_body("hello");
let new = original.clone_without_body();
assert_eq!(original.get_method(), new.get_method());
assert_eq!(original.get_url(), new.get_url());
assert_eq!(original.get_header("hello"), new.get_header("hello"));
assert_eq!(original.get_version(), new.get_version());
assert!(original.has_body());
assert!(!new.has_body());
```

**Parameters**

- `self`: `&Self`

**Returns**

`Request`

### connect

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#501

```rust
fn connect(url: impl ToUrl) -> Self
```

Create a new `CONNECT` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### contains_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1628

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

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

#### 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

```rust
let req = Request::get("https://example.com").with_header("hello", "world!");
assert!(req.contains_header("hello"));
assert!(!req.contains_header("not-present"));
```

**Parameters**

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

**Returns**

`bool`

### delete

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#494

```rust
fn delete(url: impl ToUrl) -> Self
```

Create a new `DELETE` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### fastly_key_is_valid

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2881

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

Returns whether or not the client request had a `Fastly-Key` header which is valid for
purging content for the service.

This function ignores the current value of any `Fastly-Key` header for this request.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### from_client

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#346

```rust
fn from_client() -> Request
```

Get the client request being handled by this execution of the Compute program.

#### Panics

This method panics if the client request has already been retrieved by this method or by
[the low-level handle API](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/).

#### Incompatibility with [`fastly::main`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/attr.main/)

This method cannot be used with [`fastly::main`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/attr.main/), as that attribute
implicitly calls [`Request::from_client()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-from_client) to populate the request argument. Use an
undecorated `main()` function instead, along with [`Response::send_to_client()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-send_to_client) or
[`Response::stream_to_client()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/#method-stream_to_client) to send a response to the client.

**Returns**

`Request`

### from_handles

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2801

```rust
fn from_handles(req_handle: RequestHandle, body_handle: Option<BodyHandle>) -> Self
```

Create a [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) from the low-level [`handle` API](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/).

**Parameters**

- `req_handle`: `RequestHandle`
- `body_handle`: `Option<BodyHandle>`

**Returns**

`Self`

### get

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#466

```rust
fn get(url: impl ToUrl) -> Self
```

Create a new `GET` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### get_body_mut

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#979

```rust
fn get_body_mut(&mut self) -> &mut Body
```

Get a mutable reference to the body of this request.

An empty body is returned if no body has been set, or if it has previously been returned by a method
like [`take_body()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-take_body).

#### Examples

```rust
use std::io::Write;

let mut req = Request::post("https://example.com").with_body("hello,");
write!(req.get_body_mut(), " world!")?;
assert_eq!(&req.into_body_str(), "hello, world!");
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`&mut Body`

### get_body_prefix_mut

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1007

```rust
fn get_body_prefix_mut(&mut self, length: usize) -> Prefix<'_>
```

Get a prefix of this request's body containing up to the given number of bytes.

See [`Body::get_prefix_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/#method-get_prefix_mut) for details.

**Parameters**

- `self`: `&mut Self`
- `length`: `usize`

**Returns**

`body::Prefix`

### get_body_prefix_str_mut

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1024

```rust
fn get_body_prefix_str_mut(&mut self, length: usize) -> PrefixString<'_>
```

Get a prefix of this request's body as a string containing up to the given number of bytes.

See [`Body::get_prefix_str_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/#method-get_prefix_str_mut) for details.

#### Panics

If the prefix contains invalid UTF-8 bytes, this function will panic. The exception to this
is if the bytes are invalid because a multi-byte codepoint is cut off by the requested
prefix length. In this case, the invalid bytes are left off the end of the prefix.

To explicitly handle the possibility of invalid UTF-8 bytes, use
[`try_get_body_prefix_str_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-try_get_body_prefix_str_mut), which returns an
error on failure rather than panicking.

**Parameters**

- `self`: `&mut Self`
- `length`: `usize`

**Returns**

`body::PrefixString`

### get_bot_analyzed

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2931

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

Whether bot detection analysis was performed for this request.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### get_bot_category

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2966

```rust
fn get_bot_category(&self) -> Result<Option<&str>, Utf8Error>
```

A string indicating the type of bot detected (e.g., `SEARCH-ENGINE-CRAWLER`, `AI-CRAWLER`,
`SUSPECTED-BOT`). Returns `None` if bot detection was not executed.

**Warning:** String values may change over time. Use this for logging or informational purposes.
For conditional logic, use [`get_bot_category_kind()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_bot_category_kind).

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Option<&str>, std::str::Utf8Error>`

### get_bot_category_bytes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2973

```rust
fn get_bot_category_bytes(&self) -> Option<&[u8]>
```

Like [`Self::get_bot_category`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_bot_category), but supports non-UTF-8 byte sequences.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&[u8]>`

### get_bot_category_kind

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2980

```rust
fn get_bot_category_kind(&self) -> Option<BotCategory>
```

An enum uniquely identifying the type of bot detected.
Returns `None` if bot detection was not executed.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<BotCategory>`

### get_bot_detected

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2938

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

Whether a bot was detected in the request.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### get_bot_name

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2949

```rust
fn get_bot_name(&self) -> Result<Option<&str>, Utf8Error>
```

A string identifying the specific bot detected (e.g., `GoogleBot`, `GPTBot`, `Bingbot`).
Returns `None` if bot detection was not executed or no bot was detected.

**Warning:** String values may change over time. Use this for logging or informational purposes.
For conditional logic, use [`get_bot_category_kind()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_bot_category_kind).

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Option<&str>, std::str::Utf8Error>`

### get_bot_name_bytes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2956

```rust
fn get_bot_name_bytes(&self) -> Option<&[u8]>
```

Like [`Self::get_bot_name`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_bot_name), but supports non-UTF-8 byte sequences.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&[u8]>`

### get_bot_verified

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2987

```rust
fn get_bot_verified(&self) -> Option<bool>
```

Whether the detected bot is a verified bot.
Returns `None` if bot detection was not executed or no bot was detected.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<bool>`

### get_client_ddos_detected

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2593

```rust
fn get_client_ddos_detected(&self) -> Option<bool>
```

Returns whether the request was tagged as contributing to a DDoS attack

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<bool>`

### get_client_h2_fingerprint

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2566

```rust
fn get_client_h2_fingerprint(&self) -> Option<&str>
```

Get the HTTP/2 fingerprint of client request if available

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&str>`

### get_client_ip_addr

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2532

```rust
fn get_client_ip_addr(&self) -> Option<IpAddr>
```

Returns the IP address of the client making the HTTP request.

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<IpAddr>`

### get_client_oh_fingerprint

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2584

```rust
fn get_client_oh_fingerprint(&self) -> Option<&str>
```

Get the fingerprint of client original request headers if available

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&str>`

### get_client_request_id

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2575

```rust
fn get_client_request_id(&self) -> Option<&str>
```

Get the request id of the current request if available

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&str>`

### get_content_length

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1610

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

Get the value of the request'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/request.rs#1577

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

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

#### Panics

This method panics if the `Content-Type` header is present, but its value cannot be parsed
as a valid MIME type. To handle the possibility of an invalid MIME type, use `get_header()`
to access the value directly.

#### Examples

```rust
let req = Request::post("https://example.com").with_body_text_plain("hello, world!");
assert_eq!(req.get_content_type(), Some(fastly::mime::TEXT_PLAIN_UTF_8));
```

**Parameters**

- `self`: `&Self`

**Returns**

`Option<Mime>`

### get_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1728

```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/request/struct.Request/#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

Handling UTF-8 values explicitly:

```rust
let req = Request::get("https://example.com").with_header("hello", "world!");
assert_eq!(req.get_header("hello"), Some(&HeaderValue::from_static("world")));
```

Safely handling invalid UTF-8 values:

```rust
let invalid_utf8 = &"🐈".as_bytes()[0..3];
let req = Request::get("https://example.com").with_header("hello", invalid_utf8);
assert_eq!(req.get_header("hello").unwrap().as_bytes(), invalid_utf8);
```

**Parameters**

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

**Returns**

`Option<&HeaderValue>`

### get_header_all

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1829

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

You can turn the iterator into collection, like [`Vec`](https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html):

```rust
let invalid_utf8 = &"🐈".as_bytes()[0..3];
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("hello", invalid_utf8);

let values: Vec<&HeaderValue> = req.get_header_all("hello").collect();
assert_eq!(values.len(), 2);
assert!(values.contains(&&HeaderValue::from_static("world!")));
assert!(values.contains(&&HeaderValue::from_bytes(invalid_utf8).unwrap()));
```

You can use the iterator in a loop:

```rust
let invalid_utf8 = &"🐈".as_bytes()[0..3];
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("hello", invalid_utf8);

for value in req.get_header_all("hello") {
    if let Ok(s) = std::str::from_utf8(value.as_bytes()) {
        println!("hello, {}", s);
    } else {
        println!("hello, invalid UTF-8!");
    }
}
```

**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/request.rs#1752

```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/request/struct.Request/#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/request/struct.Request/#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

```rust
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("hello", "universe!");
let values = req.get_header_all_str("hello");
assert_eq!(values.len(), 2);
assert!(values.contains(&"world!"));
assert!(values.contains(&"universe!"));
```

**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/request.rs#1784

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

```rust
let world_value = HeaderValue::from_bytes(b"\xF0\x90\x80 world!").unwrap();
let universe_value = HeaderValue::from_bytes(b"\xF0\x90\x80 universe!").unwrap();
let req = Request::get("https://example.com")
    .with_header("hello", world_value)
    .with_header("hello", universe_value);
let values = req.get_header_all_str_lossy("hello");
assert_eq!(values.len(), 2);
assert!(values.contains(&Cow::from("� world!")));
assert!(values.contains(&Cow::from("� universe!")));
```

**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/request.rs#1918

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

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

#### Examples

You can turn the iterator into collection, like [`Vec`](https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html):

```rust
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("goodbye", "latency!");

let values: Vec<&HeaderName> = req.get_header_names().collect();
assert_eq!(values.len(), 2);
assert!(values.contains(&&HeaderName::from_static("hello")));
assert!(values.contains(&&HeaderName::from_static("goodbye")));
```

You can use the iterator in a loop:

```rust
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("goodbye", "latency!");

for name in req.get_header_names() {
    println!("saw header: {:?}", name);
}
```

**Parameters**

- `self`: `&Self`

**Returns**

`impl Iterator<Item = &HeaderName>`

### get_header_names_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1883

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

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

#### Examples

```rust
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("goodbye", "latency!");
let names = req.get_header_names_str();
assert_eq!(names.len(), 2);
assert!(names.contains(&"hello"));
assert!(names.contains(&"goodbye"));
```

**Parameters**

- `self`: `&Self`

**Returns**

`Vec<&str>`

### get_header_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1663

```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/request/struct.Request/#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/request/struct.Request/#method-get_header_str_lossy) for lossy
conversion, or use [`get_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#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

```rust
let req = Request::get("https://example.com").with_header("hello", "world!");
assert_eq!(req.get_header_str("hello"), Some("world"));
```

**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/request.rs#1696

```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/request/struct.Request/#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

```rust
let header_value = HeaderValue::from_bytes(b"\xF0\x90\x80 world!").unwrap();
let req = Request::get("https://example.com").with_header("hello", header_value);
assert_eq!(req.get_header_str_lossy("hello"), Some(Cow::from("� world")));
```

**Parameters**

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

**Returns**

`Option<Cow<str>>`

### get_headers

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1864

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

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

#### Examples

You can turn the iterator into a collection, like [`Vec`](https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html):

```rust
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("hello", "universe!");

let headers: Vec<(&HeaderName, &HeaderValue)> = req.get_headers().collect();
assert_eq!(headers.len(), 2);
assert!(headers.contains(&(&HeaderName::from_static("hello"), &HeaderValue::from_static("world!"))));
assert!(headers.contains(&(&HeaderName::from_static("hello"), &HeaderValue::from_static("universe!"))));
```

You can use the iterator in a loop:

```rust
let req = Request::get("https://example.com")
    .with_header("hello", "world!")
    .with_header("hello", "universe!");

for (n, v) in req.get_headers() {
    println!("Header -  {}: {:?}", n, v);
}
```

**Parameters**

- `self`: `&Self`

**Returns**

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

### get_method

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2086

```rust
fn get_method(&self) -> &Method
```

Get the request method.

#### Examples

```rust
use fastly::http::Method;
fn log_method(req: &Request) {
    match req.get_method() {
        &Method::GET | &Method::HEAD => println!("method was a GET or HEAD"),
        &Method::POST => println!("method was a POST"),
        _ => println!("method was something else"),
    }
}

**Parameters**

- `self`: `&Self`

**Returns**

`&Method`

### get_method_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2068

```rust
fn get_method_str(&self) -> &str
```

Get the request method as a string.

#### Examples

```rust
let req = Request::get("https://example.com");
assert_eq!(req.get_method_str(), "GET");

**Parameters**

- `self`: `&Self`

**Returns**

`&str`

### get_original_header_count

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2559

```rust
fn get_original_header_count(&self) -> Option<u32>
```

Returns the number of headers in the client request as originally received.

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<u32>`

### get_original_header_names

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2549

```rust
fn get_original_header_names(&self) -> Result<Option<&[String]>, BufferSizeError>
```

Returns the client request's header names exactly as they were originally received.

This includes both the original character cases, as well as the original order of the
received headers.

Returns `Ok(None)` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Option<&[String]>, BufferSizeError>`

### get_path

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2178

```rust
fn get_path(&self) -> &str
```

Get the path component of the request URL.

#### Examples

```rust
let req = Request::get("https://example.com/hello#world");
assert_eq!(req.get_path(), "/hello");
```

**Parameters**

- `self`: `&Self`

**Returns**

`&str`

### get_query

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2278

```rust
fn get_query<T: DeserializeOwned>(&self) -> Result<T, Error>
```

Attempt to parse the query component of the request URL into the specified datatype.

The return type chosen for this function must implement [`serde::de::Deserialize`](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.Deserialize.html) without any
non-static lifetimes; see the trait documentation for details.

#### Errors

This method returns [`serde_urlencoded::de::Error`](https://docs.rs/serde_core/1.0.228/serde_core/de/value/struct.Error.html) if deserialization fails.

#### Examples

Parsing into a vector of string pairs:

```rust
let req = Request::get("https://example.com/foo?hello=%F0%9F%8C%90!&bar=baz");
let pairs: Vec<(String, String)> = req.get_query().unwrap();
assert_eq!((pairs[0].0.as_str(), pairs[0].1.as_str()), ("hello", "🌐!"));
```

Parsing into a mapping between strings (note that duplicates are removed since
[`HashMap`](https://doc.rust-lang.org/stable/std/collections/hash/map/struct.HashMap.html) is not a multimap):

```rust
use std::collections::HashMap;
let req = Request::get("https://example.com/foo?hello=%F0%9F%8C%90!&bar=baz&bar=quux");
let map: HashMap<String, String> = req.get_query().unwrap();
assert_eq!(map.len(), 2);
assert_eq!(map["hello"].as_str(), "🌐!");
```

Parsing into a custom type that derives [`serde::de::Deserialize`](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.Deserialize.html):

```rust
#[derive(serde::Deserialize)]
struct MyData {
    name: String,
    count: u64,
}
let mut req = Request::get("https://example.com/?name=Computers&count=1024");
let my_data = req.take_body_form::<MyData>().unwrap();
assert_eq!(&my_data.name, "Computers");
assert_eq!(my_data.count, 1024);
```

**Parameters**

- `self`: `&Self`

**Returns**

`Result<T, serde_urlencoded::de::Error>`

### get_query_parameter

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2224

```rust
fn get_query_parameter(&self, parameter: &str) -> Option<&str>
```

Get the value of a query parameter in the request's URL.

This assumes that the query string is a `&` separated list of `parameter=value` pairs.  The
value of the first occurrence of `parameter` is returned. No URL decoding is performed.

#### Examples

```rust
let req = Request::get("https://example.com/page?foo=bar&baz=qux");
assert_eq!(req.get_query_parameter("foo"), Some("bar"));
assert_eq!(req.get_query_parameter("baz"), Some("qux"));
assert_eq!(req.get_query_parameter("other"), None);
```

**Parameters**

- `self`: `&Self`
- `parameter`: `&str`

**Returns**

`Option<&str>`

### get_query_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2206

```rust
fn get_query_str(&self) -> Option<&str>
```

Get the query component of the request URL, if it exists, as a percent-encoded ASCII string.

This is a shorthand for `self.get_url().query()`; see [`Url::query()`](https://docs.rs/url/2.5.7/url/Url/fn.query.html) for details and other
query manipulation functions.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&str>`

### get_server_ip_addr

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2539

```rust
fn get_server_ip_addr(&self) -> Option<IpAddr>
```

Returns the IP address on which this server received the HTTP request.

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<IpAddr>`

### get_tls_cipher_openssl_name

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2711

```rust
fn get_tls_cipher_openssl_name(&self) -> Result<Option<&str>, Utf8Error>
```

Get the cipher suite used to secure the client TLS connection, as a string,
panicking if it is not UTF-8.

The value returned will be consistent with the [OpenSSL
name](https://testssl.sh/openssl-iana.mapping.html) for the cipher suite.

Returns `None` if this is not the client request.

#### Examples

```rust
assert_eq!(
    Request::from_client().get_tls_cipher_openssl_name().unwrap(),
    Some("ECDHE-RSA-AES128-GCM-SHA256"),
);
```

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Option<&str>, std::str::Utf8Error>`

### get_tls_cipher_openssl_name_bytes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2728

```rust
fn get_tls_cipher_openssl_name_bytes(&self) -> Option<&[u8]>
```

Like [`Self::get_tls_cipher_openssl_name_bytes`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_tls_cipher_openssl_name_bytes), but supports non-UTF-8 byte strings.

#### Examples

```rust
assert_eq!(
    Request::from_client().get_tls_cipher_openssl_name_bytes(),
    Some("ECDHE-RSA-AES128-GCM-SHA256".as_bytes()),
);
```

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&[u8]>`

### get_tls_client_cert_verify_result

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2689

```rust
fn get_tls_client_cert_verify_result(&self) -> Option<ClientCertVerifyResult>
```

Returns the error code defined in ClientCertVerifyResult.

If your service is set up for mTLS (see [this documentation](https://docs.fastly.com/en/guides/setting-up-mutual-tls-authentication)),
then this will return information about the client's mTLS certificate, if provided.
If the certificate is not provided, you will receive a `ClientCertVerifyResult::CertificateMissing`
value, if the certificate properly matches your mTLS configuration, you will receive
a `ClientCertVerifyResult::Ok`, etc.

If your service is *not* set up for mTLS, this function will always return
`Some(ClientCertVerifyResult::Ok)`.

If you have a service that may be run with some domains that are mTLS protected,
and some that are not mTLS protected, then we advise checking for both the existence
of a certificate (by verifying that `get_tls_raw_client_certificate` or
`get_tls_raw_client_certificate_bytes` return `Some`) before checking the result of
this function. Doing both makes sure that you both received a certificate and that
it was valid, and will work for both the mTLS-protected and non-mTLS-protected
domains.

This function returns `None` in the case that this `Request` is not from the
client, but was instead generated by other parts of the code. (In other words,
it will return `None` if this request was neither the argument to a function marked
`fastly::main` nor generated with `Request::from_client`.)

**Parameters**

- `self`: `&Self`

**Returns**

`Option<ClientCertVerifyResult>`

### get_tls_client_hello

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2603

```rust
fn get_tls_client_hello(&self) -> Option<&[u8]>
```

Get the raw bytes sent by the client in the TLS ClientHello message.

See [RFC 5246](https://tools.ietf.org/html/rfc5246#section-7.4.1.2) for details.

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&[u8]>`

### get_tls_client_servername

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2613

```rust
fn get_tls_client_servername(&self) -> Option<&str>
```

Get the hostname sent by the client in the TLS ServerName Indication.

See [RFC 6066](https://tools.ietf.org/html/rfc6066#section-3) for details.

Returns `None` if this is not the client request.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&str>`

### get_tls_ja3_md5

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2621

```rust
fn get_tls_ja3_md5(&self) -> Option<[u8; 16]>
```

Get the JA3 hash of the TLS ClientHello message.

Returns `None` if this is not available.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<[u8; 16]>`

### get_tls_ja4

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2629

```rust
fn get_tls_ja4(&self) -> Option<&str>
```

Get the JA4 hash of the TLS ClientHello message.

Returns `None` if this is not available.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&str>`

### get_tls_protocol

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2744

```rust
fn get_tls_protocol(&self) -> Result<Option<&str>, Utf8Error>
```

Get the TLS protocol version used to secure the client TLS connection, as a string,
panicking if it is not UTF-8.

Returns `None` if this is not the client request.

#### Examples

```rust
assert_eq!(Request::from_client().get_tls_protocol().unwrap(), Some("TLSv1.2"));
```

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Option<&str>, std::str::Utf8Error>`

### get_tls_protocol_bytes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2758

```rust
fn get_tls_protocol_bytes(&self) -> Option<&[u8]>
```

Like [`Self::get_tls_protocol`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_tls_protocol), but supports non-UTF-8 byte strings.

#### Examples

```rust
assert_eq!(Request::from_client().get_tls_protocol_bytes(), Some("TLSv1.2".as_bytes()));
```

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&[u8]>`

### get_tls_raw_client_certificate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2654

```rust
fn get_tls_raw_client_certificate(&self) -> Result<Option<&str>, Utf8Error>
```

Get the raw client certificate in the mutual TLS handshake message as a
string, panicking if it is not UTF-8.
It is in PEM format.

If this is not mTLS or available then this will return `Ok(None)`.

**Parameters**

- `self`: `&Self`

**Returns**

`Result<Option<&str>, std::str::Utf8Error>`

### get_tls_raw_client_certificate_bytes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2661

```rust
fn get_tls_raw_client_certificate_bytes(&self) -> Option<&[u8]>
```

Like [`Self::get_tls_raw_client_certificate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_tls_raw_client_certificate), but supports non-UTF-8 byte sequences.

**Parameters**

- `self`: `&Self`

**Returns**

`Option<&[u8]>`

### get_url

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2139

```rust
fn get_url(&self) -> &Url
```

Get a shared reference to the request URL.

#### Examples

```rust
let req = Request::get("https://example.com/hello#world");
let url = req.get_url();
assert_eq!(url.host_str(), Some("example.com"));
assert_eq!(url.path(), "/hello");
assert_eq!(url.fragment(), Some("world"));
```

**Parameters**

- `self`: `&Self`

**Returns**

`&Url`

### get_url_mut

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2158

```rust
fn get_url_mut(&mut self) -> impl DerefMut<Target = Url> + '_
```

Get a mutable reference to the request URL.

#### Examples

```rust
let mut req = Request::get("https://example.com/");

let mut url = req.get_url_mut();
url.set_path("/hello");
url.set_fragment(Some("world"));
drop(url);

assert_eq!(req.get_url_str(), "https://example.com/hello#world");
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`impl DerefMut<Target = Url> + '_`

### get_url_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2123

```rust
fn get_url_str(&self) -> &str
```

Get the request URL as a string.

#### Examples

```rust
let req = Request::get("https://example.com");
assert_eq!(req.get_url_str(), "https://example.com");
```

**Parameters**

- `self`: `&Self`

**Returns**

`&str`

### get_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2366

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

Get the HTTP version of this request.

**Parameters**

- `self`: `&Self`

**Returns**

`Version`

### handoff_fanout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3029

```rust
fn handoff_fanout(self, backend: &str) -> Result<(), SendError>
```

Pass the request through the Fanout GRIP proxy and on to a backend.

This can only be used on services that have the Fanout feature enabled.

The sending completes in the background. Once this method has been called, no other
response can be sent to this request, and the application can exit without affecting the
send.

**Parameters**

- `self`: `Self`
- `backend`: `&str`

**Returns**

`Result<(), SendError>`

### handoff_websocket

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3000

```rust
fn handoff_websocket(self, backend: &str) -> Result<(), SendError>
```

Pass the WebSocket directly to a backend.

This can only be used on services that have the WebSockets feature enabled and on requests
that are valid WebSocket requests.

The sending completes in the background. Once this method has been called, no other
response can be sent to this request, and the application can exit without affecting the
send.

**Parameters**

- `self`: `Self`
- `backend`: `&str`

**Returns**

`Result<(), SendError>`

### has_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#959

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

Returns `true` if this request has a body.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### head

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#473

```rust
fn head(url: impl ToUrl) -> Self
```

Create a new `HEAD` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### into_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1152

```rust
fn into_body(self) -> Body
```

Consume the request and return its body.

An empty body is returned if no body has been set, or if it has previously been returned by a method
like [`take_body()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-take_body).

**Parameters**

- `self`: `Self`

**Returns**

`Body`

### into_body_bytes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1106

```rust
fn into_body_bytes(self) -> Vec<u8>
```

Consume the request and return its body as a byte vector.

#### Memory usage

This method will cause the entire body to be buffering in WebAssembly memory. You should take care
not to exceed the WebAssembly memory limits, and consider using methods like
[`read_body_lines()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_lines) or
[`read_body_chunks()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_chunks) to control how much of the body you process at
once.

#### Examples

```rust
let req = Request::post("https://example.com").with_body_text_plain("hello, world!");
let bytes = req.into_body_bytes();
assert_eq!(&bytes, b"hello, world!");

**Parameters**

- `self`: `Self`

**Returns**

`Vec<u8>`

### into_body_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1126

```rust
fn into_body_str(self) -> String
```

Consume the request and return its body as a string.

#### Memory usage

This method will cause the entire body to be buffering in WebAssembly memory. You should take care
not to exceed the WebAssembly memory limits, and consider using methods like
[`read_body_lines()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_lines) or
[`read_body_chunks()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_chunks) to control how much of the body you process at
once.

#### Panics

If the body does not contain a valid UTF-8 string, this function will panic. To explicitly handle
the possibility of invalid UTF-8 data, use [`into_body_str_lossy()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-into_body_str_lossy)
for lossy conversion, or use [`into_body_bytes()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-into_body_bytes) and then convert the
bytes explicitly with a function like [`String::from_utf8`](https://doc.rust-lang.org/stable/alloc/string/String/fn.from_utf8.html).

#### Examples

```rust
let req = Request::post("https://example.com").with_body("hello, world!");
let string = req.into_body_str();
assert_eq!(&string, "hello, world!");
```

**Parameters**

- `self`: `Self`

**Returns**

`String`

### into_body_str_lossy

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1145

```rust
fn into_body_str_lossy(self) -> String
```

Consume the request and return its body as a string, including invalid characters.

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

#### Memory usage

This method will cause the entire body to be buffering in WebAssembly memory. You should take care
not to exceed the WebAssembly memory limits, and consider using methods like
[`read_body_lines()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_lines) or
[`read_body_chunks()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_chunks) to control how much of the body you process at
once.

#### Examples

```rust
let mut req = Request::post("https://example.com");
req.set_body_octet_stream(b"\xF0\x90\x80 hello, world!");
let string = req.into_body_str_lossy();
assert_eq!(&string, "� hello, world!");
```

**Parameters**

- `self`: `Self`

**Returns**

`String`

### into_handles

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2853

```rust
fn into_handles(self) -> (RequestHandle, Option<BodyHandle>)
```

Convert a [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) into the low-level [`handle` API](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/).

**Parameters**

- `self`: `Self`

**Returns**

`(RequestHandle, Option<BodyHandle>)`

### is_cacheable

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3081

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

Gets whether the request is potentially cacheable.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### is_from_client

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#355

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

Return `true` if this request is from the client of this execution of the Compute
program.

**Parameters**

- `self`: `&Self`

**Returns**

`bool`

### new

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#366

```rust
fn new(method: impl ToMethod, url: impl ToUrl) -> Self
```

Create a new request with the given method and URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `method`: `impl ToMethod`
- `url`: `impl ToUrl`

**Returns**

`Self`

### on_behalf_of

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3056

```rust
fn on_behalf_of<S: AsRef<str>>(self, service: S) -> Result<Self, FastlyStatus>
```

Send this request on behalf of another service.

Running it on behalf of another service means that the cache store used for this request
will be of that service, not the currently running one.
#### Internal / Privileged

This operation is privileged, and attempts to use this functionality without
proper privileges will cause errors. If you are interested in having two or
more of your services share the same cache, please talk to your Fastly account
representative. While we have no plans to offer this ability widely -- this
capability is only currently allowed for Fastly-internal services -- we may
revisit this decision given sufficient customer input.

**Parameters**

- `self`: `Self`
- `service`: `S`

**Returns**

`Result<Self, FastlyStatus>`

### options

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

```rust
fn options(url: impl ToUrl) -> Self
```

Create a new `OPTIONS` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### patch

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#522

```rust
fn patch(url: impl ToUrl) -> Self
```

Create a new `PATCH` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### post

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#480

```rust
fn post(url: impl ToUrl) -> Self
```

Create a new `POST` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### put

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#487

```rust
fn put(url: impl ToUrl) -> Self
```

Create a new `PUT` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### read_body_chunks

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1355

```rust
fn read_body_chunks(&mut self, chunk_size: usize) -> impl Iterator<Item = Result<Vec<u8>, Error>> + '_
```

Return an iterator that reads the request body in chunks of at most the given number of
bytes.

If `chunk_size` does not evenly divide the length of the body, then the last chunk will not
have length `chunk_size`.

#### Examples

```rust
use std::io::Write;
fn remove_0s(req: &mut Request) -> Result<(), Box<dyn std::error::Error>> {
    let mut no_0s = Body::new();
    for chunk in req.read_body_chunks(4096) {
        let mut chunk = chunk?;
        chunk.retain(|b| *b != 0);
        no_0s.write_all(&chunk)?;
    }
    req.set_body(no_0s);
    Ok(())
}
```

**Parameters**

- `self`: `&mut Self`
- `chunk_size`: `usize`

**Returns**

`impl Iterator<Item = Result<Vec<u8>, Error>> + '_`

### read_body_lines

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1281

```rust
fn read_body_lines(&mut self) -> Lines<&mut Body>
```

Return a [`Lines`](https://doc.rust-lang.org/stable/alloc/io/util/struct.Lines.html) iterator that reads the request body a line at a time.

#### Examples

```rust
use std::io::Write;

fn remove_es(req: &mut Request) -> Result<(), Box<dyn std::error::Error>> {
    let mut no_es = Body::new();
    for line in req.read_body_lines() {
        writeln!(no_es, "{}", line.unwrap().replace("e", ""))?;
    }
    req.set_body(no_es);
    Ok(())
}
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`std::io::Lines<&mut Body>`

### remove_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1993

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

Remove all request 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, use [`get_header_all()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#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

```rust
let mut req = Request::get("https://example.com").with_header("hello", "world!");
assert_eq!(req.get_header_str("hello"), Some("world!"));
assert_eq!(req.remove_header("hello"), Some(HeaderValue::from_static("world!")));
assert!(req.remove_header("not-present").is_none());
```

**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/request.rs#2018

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

Remove all request 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/request/struct.Request/#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/request/struct.Request/#method-remove_header_str_lossy) for lossy
conversion, or use [`remove_header()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#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

```rust
let mut req = Request::get("https://example.com").with_header("hello", "world!");
assert_eq!(req.get_header_str("hello"), Some("world!"));
assert_eq!(req.remove_header_str("hello"), Some("world!".to_string()));
assert!(req.remove_header_str("not-present").is_none());
```

**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/request.rs#2049

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

Remove all request 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/request/struct.Request/#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

```rust
let header_value = HeaderValue::from_bytes(b"\xF0\x90\x80 world!").unwrap();
let mut req = Request::get("https://example.com")
    .with_header("hello", header_value);
assert_eq!(req.get_header_str_lossy("hello"), Some(Cow::from("� world")));
assert_eq!(req.remove_header_str_lossy("hello"), Some(String::from("� world")));
assert!(req.remove_header_str_lossy("not-present").is_none());
```

**Parameters**

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

**Returns**

`Option<String>`

### remove_query

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2355

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

Remove the query component from the request URL, if one exists.

#### Examples

```rust
let mut req = Request::get("https://example.com/foo?hello=%F0%9F%8C%90!&bar=baz");
req.remove_query();
assert_eq!(req.get_url_str(), "https://example.com/foo");
```

**Parameters**

- `self`: `&mut Self`

### send

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#606

```rust
fn send(self, backend: impl ToBackend) -> Result<Response, SendError>
```

Retrieve a response for the request, either from cache or by sending it to the given backend
server. Returns once the response headers have been received, or an error occurs.

#### Argument type conversion

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

#### Examples

Sending the client request to a backend without modification:

```rust
let backend_resp = Request::from_client().send("example_backend").expect("request succeeds");
assert!(backend_resp.get_status().is_success());
```

Sending a synthetic request:

```rust
let backend_resp = Request::get("https://example.com")
    .send("example_backend")
    .expect("request succeeds");
assert!(backend_resp.get_status().is_success());
```

**Parameters**

- `self`: `Self`
- `backend`: `impl ToBackend`

**Returns**

`Result<Response, SendError>`

### send_async

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#836

```rust
fn send_async(self, backend: impl ToBackend) -> Result<PendingRequest, SendError>
```

Begin sending the request to the given backend server, and return a [`PendingRequest`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/) that
can yield the backend response or an error.

This method returns as soon as the request begins sending to the backend, and transmission
of the request body and headers will continue in the background.

This method allows for sending more than one request at once and receiving their responses
in arbitrary orders. See [`PendingRequest`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/) for more details on how to wait on, poll, or
select between pending requests.

This method is also useful for sending requests where the response is unimportant, but the
request may take longer than the Compute program is able to run, as the request will
continue sending even after the program that initiated it exits.

#### Argument type conversion

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

#### Examples

Sending a request to two backends and returning whichever response finishes first:

```rust
let backend_resp_1 = Request::get("https://example.com/")
    .send_async("example_backend_1")
    .expect("request 1 begins sending");
let backend_resp_2 = Request::get("https://example.com/")
    .send_async("example_backend_2")
    .expect("request 2 begins sending");
let (resp, _) = fastly::http::request::select(vec![backend_resp_1, backend_resp_2]);
resp.expect("request succeeds").send_to_client();
```

Sending a long-running request and ignoring its result so that the program can exit before
it completes:

```rust
let _ = Request::post("https://example.com")
    .with_body(some_large_file)
    .send_async("example_backend");
```

**Parameters**

- `self`: `Self`
- `backend`: `impl ToBackend`

**Returns**

`Result<PendingRequest, SendError>`

### send_async_streaming

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#918

```rust
fn send_async_streaming(self, backend: impl ToBackend) -> Result<(StreamingBody, PendingRequest), SendError>
```

Begin sending the request to the given backend server, and return a [`PendingRequest`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/) that
can yield the backend response or an error along with a [`StreamingBody`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.StreamingBody/) that can accept
further data to send.

The backend connection is only closed once [`StreamingBody::finish()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.StreamingBody/#method-finish) is called. The
[`PendingRequest`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.PendingRequest/) will not yield a [`Response`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/struct.Response/) until the [`StreamingBody`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.StreamingBody/) is finished.

This method is most useful for programs that do some sort of processing or inspection of a
potentially-large client request body. Streaming allows the program to operate on small
parts of the body rather than having to read it all into memory at once.

This method returns as soon as the request begins sending to the backend, and transmission
of the request body and headers will continue in the background.

Note that the implementation of `send_async_streaming` does not currently support also using
[Request::set_before_send](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_before_send) or [Request::set_after_send](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send). Attempts to call this method after
also setting the callbacks will result in an [SendErrorCause::HttpCacheApiUnsupported](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/enum.SendErrorCause/)
error.

#### Examples

Count the number of lines in a UTF-8 client request body while sending it to the backend:

```rust
use std::io::{BufRead, Write};

let mut req = Request::from_client();
// Take the body so we can iterate through its lines later
let req_body = req.take_body();
// Start sending the client request to the client with a now-empty body
let (mut backend_body, pending_req) = req
    .send_async_streaming("example_backend")
    .expect("request begins sending");

let mut num_lines = 0;
for line in req_body.lines() {
    let line = line?;
    num_lines += 1;
    // Write the line to the streaming backend body
    backend_body.write_all(line.as_bytes())?;
}
// Finish the streaming body to allow the backend connection to close
backend_body.finish()?;

println!("client request body contained {} lines", num_lines);
```

**Parameters**

- `self`: `Self`
- `backend`: `impl ToBackend`

**Returns**

`Result<(StreamingBody, PendingRequest), SendError>`

### set_after_send

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#573

```rust
fn set_after_send(&mut self, f: impl Fn(&mut CandidateResponse) -> Result<(), SendErrorCause> + Send + Sync + 'static)
```

Sets a callback to be invoked after a response is returned from a
backend, but before it is stored into the cache.

This callback allows for cache properties like TTL to be customized
beyond what the backend response headers specify. It also allows for the
response itself to be modified prior to storing into the cache.

Note that the callback is only invoked if the request is a candidate for caching; it is not
invoked if the request is explicitly to the backend with [`Request::set_pass()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass).

**Parameters**

- `self`: `&mut Self`
- `f`: `impl Fn(&mut CandidateResponse) -> Result<(), SendErrorCause> + Send + Sync + 'static`

### set_auto_decompress_gzip

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2772

```rust
fn set_auto_decompress_gzip(&mut self, gzip: bool)
```

Set whether a `gzip`-encoded response to this request will be automatically decompressed.

Enabling this will set the `Accept-Encoding` header before the request is sent, regardless
of the original value in the request, to ensure that any values originally sent by a
browser or other client get replaced with `gzip`, so that the backend will not try sending
unsupported compression algorithms.

If the response to this request is `gzip`-encoded, it will be presented in decompressed
form, and the `Content-Encoding` and `Content-Length` headers will be removed.

**Parameters**

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

### set_before_send

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#546

```rust
fn set_before_send(&mut self, f: impl Fn(&mut Request) -> Result<(), SendErrorCause> + Send + Sync + 'static)
```

Sets a callback to be invoked if a request misses the cache,
allowing the request to be modified beforehand.

This callback is useful when, for example, a backend requires an
additional header to be inserted, but that header is expensive to
produce. The callback will only be invoked if the original request
cannot be responded to from the cache, so the header is only computed
when it is truly needed.

Note that the callback is only invoked if the request is a candidate for caching; it is not
invoked if the request is explicitly to the backend with [`Request::set_pass()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass).

**Parameters**

- `self`: `&mut Self`
- `f`: `impl Fn(&mut Request) -> Result<(), SendErrorCause> + Send + Sync + 'static`

### set_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1041

```rust
fn set_body(&mut self, body: impl Into<Body>)
```

Set the given value as the request's body.
#### Argument type conversion

See the `From` impls for [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/) to see which types can be used as a body.
Any previous body that may have been set on the response is discarded. To add to an existing body,
use [`get_body_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_body_mut) and write to the returned [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/).

**Parameters**

- `self`: `&mut Self`
- `body`: `impl Into<Body>`

### set_body_form

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1514

```rust
fn set_body_form(&mut self, value: &impl Serialize) -> Result<(), Error>
```

Convert the given value to `application/x-www-form-urlencoded` format and set that data as
the request's body.

The given value must implement [`serde::Serialize`](https://docs.rs/serde_core/1.0.228/serde_core/ser/trait.Serialize.html); see the trait documentation for
details.

Any previous body that may have been set on the response is discarded. To add to an existing body,
use [`get_body_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_body_mut) and write to the returned [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/).

#### Content type

This method sets the content type to `application/x-www-form-urlencoded`.

#### Errors

This method returns [`serde_urlencoded::ser::Error`](https://docs.rs/serde_urlencoded/latest/serde_urlencoded/ser/enum.Error.html) if serialization fails.

#### Examples

```rust
#[derive(serde::Serialize)]
struct MyData {
    name: String,
    count: u64,
}
let my_data = MyData { name: "Computers".to_string(), count: 1024 };
let mut req = Request::post("https://example.com");
req.set_body_form(&my_data).unwrap();
assert_eq!(req.get_content_type(), Some(fastly::mime::APPLICATION_WWW_FORM_URLENCODED));
assert_eq!(&req.into_body_str(), "name=Computers&count=1024");
```

**Parameters**

- `self`: `&mut Self`
- `value`: `&impl Serialize`

**Returns**

`Result<(), serde_urlencoded::ser::Error>`

### set_body_json

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1415

```rust
fn set_body_json(&mut self, value: &impl Serialize) -> Result<(), Error>
```

Convert the given value to JSON and set that JSON as the request's body.

The given value must implement [`serde::Serialize`](https://docs.rs/serde_core/1.0.228/serde_core/ser/trait.Serialize.html). You can either implement that trait for
your own custom type, or use [`serde_json::Value`](https://docs.rs/serde_json/1.0.145/serde_json/value/enum.Value.html) to create untyped JSON values. See
[`serde_json`](https://docs.rs/serde_json/1.0.145/serde_json/index.html) for details.

Any previous body that may have been set on the response is discarded. To add to an existing body,
use [`get_body_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_body_mut) and write to the returned [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/).

#### Content type

This method sets the content type to `application/json`.

#### Errors

This method returns [`serde_json::Error`](https://docs.rs/serde_json/1.0.145/serde_json/error/struct.Error.html) if serialization fails.

#### Examples

Using a type that derives [`serde::Serialize`](https://docs.rs/serde_core/1.0.228/serde_core/ser/trait.Serialize.html):

```rust
#[derive(serde::Serialize)]
struct MyData {
    name: String,
    count: u64,
}
let my_data = MyData { name: "Computers".to_string(), count: 1024 };
let mut req = Request::post("https://example.com");
req.set_body_json(&my_data).unwrap();
assert_eq!(req.get_content_type(), Some(fastly::mime::APPLICATION_JSON));
assert_eq!(&req.into_body_str(), r#"{"name":"Computers","count":1024}"#);
```

Using untyped JSON and the [`serde_json::json`](https://docs.rs/serde_json/1.0.145/serde_json/macro.json.html) macro:

```rust
let my_data = serde_json::json!({
    "name": "Computers",
    "count": 1024,
});
let mut req = Request::post("https://example.com");
req.set_body_json(&my_data).unwrap();
assert_eq!(req.get_content_type(), Some(fastly::mime::APPLICATION_JSON));
assert_eq!(&req.into_body_str(), r#"{"count":1024,"name":"Computers"}"#);
```

**Parameters**

- `self`: `&mut Self`
- `value`: `&impl Serialize`

**Returns**

`Result<(), serde_json::Error>`

### set_body_octet_stream

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1305

```rust
fn set_body_octet_stream(&mut self, body: &[u8])
```

Set the given bytes as the request's body.

Any previous body that may have been set on the response is discarded. To add to an existing body,
use [`get_body_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_body_mut) and write to the returned [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/).
#### Content type

This method sets the content type to `application/octet-stream`.

#### Examples

```rust
let mut req = Request::post("https://example.com");
req.set_body_octet_stream(b"hello, world!");
assert_eq!(req.get_content_type(), Some(fastly::mime::APPLICATION_OCTET_STREAM));
assert_eq!(&req.into_body_bytes(), b"hello, world!");
```

**Parameters**

- `self`: `&mut Self`
- `body`: `&[u8]`

### set_body_text_html

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1206

```rust
fn set_body_text_html(&mut self, body: &str)
```

Set the given string as the request's body with content type `text/html; charset=UTF-8`.

Any previous body that may have been set on the response is discarded. To add to an existing body,
use [`get_body_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_body_mut) and write to the returned [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/).
#### Content type

This method sets the content type to `text/html; charset=utf-8`.

#### Examples

```rust
let mut req = Request::post("https://example.com");
req.set_body_text_html("<p>hello, world!</p>");
assert_eq!(req.get_content_type(), Some(fastly::mime::TEXT_HTML_UTF_8));
assert_eq!(&req.into_body_str(), "<p>hello, world!</p>");
```

**Parameters**

- `self`: `&mut Self`
- `body`: `&str`

### set_body_text_plain

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1181

```rust
fn set_body_text_plain(&mut self, body: &str)
```

Set the given string as the request's body with content type `text/plain; charset=UTF-8`.

Any previous body that may have been set on the response is discarded. To add to an existing body,
use [`get_body_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-get_body_mut) and write to the returned [`Body`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/).
#### Content type

This method sets the content type to `text/plain; charset=utf-8`.

#### Examples

```rust
let mut req = Request::post("https://example.com");
req.set_body_text_plain("hello, world!");
assert_eq!(req.get_content_type(), Some(fastly::mime::TEXT_PLAIN_UTF_8));
assert_eq!(&req.into_body_str(), "hello, world!");
```

**Parameters**

- `self`: `&mut Self`
- `body`: `&str`

### set_cache_key

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3070

```rust
fn set_cache_key(&mut self, key: impl Into<Vec<u8>>)
```

Set the cache key to be used when attempting to satisfy this request from a cached response.

The cache key must be exactly 32 bytes long.

**Parameters**

- `self`: `&mut Self`
- `key`: `impl Into<Vec<u8>>`

### set_content_type

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1603

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

Set the MIME type described by the request'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

```rust
let mut req = Request::post("https://example.com").with_body("hello,world!");
req.set_content_type(fastly::mime::TEXT_CSV_UTF_8);
```

**Parameters**

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

### set_framing_headers_mode

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2789

```rust
fn set_framing_headers_mode(&mut self, mode: FramingHeadersMode)
```

Sets how `Content-Length` and `Transfer-Encoding` will be determined when sending this
request.

See [`FramingHeadersMode`](https://docs.rs/fastly_shared/latest/fastly_shared/enum.FramingHeadersMode.html) for details on the options.

**Parameters**

- `self`: `&mut Self`
- `mode`: `FramingHeadersMode`

### set_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1943

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

Set a request 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

```rust
let mut req = Request::get("https://example.com");

req.set_header("hello", "world!");
assert_eq!(req.get_header_str("hello"), Some("world!"));

req.set_header("hello", "universe!");

let values = req.get_header_all_str("hello");
assert_eq!(values.len(), 1);
assert!(!values.contains(&"world!"));
assert!(values.contains(&"universe!"));
```

**Parameters**

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

### set_image_optimizer

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3142

```rust
fn set_image_optimizer(&mut self, options: ImageOptimizerOptions)
```

Set [`image_optimizer::ImageOptimizerOptions`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/struct.ImageOptimizerOptions/) for this request to proxy it
to Image Optimizer.

Transformations can be expressed through `ImageOptimizerOptions`
or query parameters on the request. Options set on `ImageOptimizerOptions`
take precedence over query parameters with the same name.

It is not necessary to include additional shielding logic for Image Optimization,
the required [`ImageOptimizerRegion`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/image_optimizer/enum.ImageOptimizerRegion/)
handles this for you. It is recommended to pick a region close to your origin.

#### Examples
Send a request for `image.jpeg` with params `format=webp` to Image Optimizer.

```rust
let mut image_opto_opts = ImageOptimizerOptions::from_region(ImageOptimizerRegion::UsWest);
image_opto_opts.format = Some(Format::WebP);
let mut req = Request::get("https://example.com/image.jpeg");
req.set_image_optimizer(image_opto_opts);
// `origin` is a named backend on your service.
req.send("origin")?;
```

Override the `format` parameter on the request if it exists, turning it to `auto`.
```rust
#[fastly::main]
fn main(mut req: Request) -> Result<Response, Error> {
let mut image_opto_opts = ImageOptimizerOptions::from_region(ImageOptimizerRegion::UsWest);
if let Some(_param) = req.get_query_parameter("format") {
    image_opto_opts.format = Some(Format::Auto);
}
req.set_image_optimizer(image_opto_opts);
Ok(req.send("origin")?)
}
```

#### Overrides

At the moment, calling this function overrides custom caching behavior, such as
[`Request::set_surrogate_key()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl) and [`Request::set_pci()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci).
Caching behavior is currently determined by the cache control headers set on the source
image.

Additionally, any before and after send hooks are not executed.

**Parameters**

- `self`: `&mut Self`
- `options`: `image_optimizer::ImageOptimizerOptions`

### set_lookup_timeout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2523

```rust
fn set_lookup_timeout(&mut self, lookup_timeout: Duration)
```

Configure a cache lookup timeout.

By default, the Compute platform uses request collapsing: if two concurrent requests would
use the same cache entry, only one of them is directed to fetch from the backend, and the
other is directed to wait for the cache to be filled.

In some cases, this is undesirable. This bounds the time during which the request will wait
for a cached response. If this timeout is exceeded, the request is cancelled with an error,
without having been sent to the origin.

NOTE: When this timeout occurs, the request is lost; it is not retried.

Note that calling [`set_pass(true)`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) will override anything previously set by
[`Request::set_surrogate_key`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl), [`Request::set_pci`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci), and
[`Request::set_stale_while_revalidate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_stale_while_revalidate). If you wish to unconditionally call `set_pass`,
then you may want to instead use the [`CandidateResponse`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/) equivalents of those methods
inside of a [`Request::set_after_send`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send) callback.

Conversely, calling any of those methods on Request *after* calling `set_pass(true)` will
reverse the effect of the `set_pass` call, and any response received when the
request is sent may become cacheable.

**Parameters**

- `self`: `&mut Self`
- `lookup_timeout`: `std::time::Duration`

### set_method

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2104

```rust
fn set_method(&mut self, method: impl ToMethod)
```

Set the request method.

#### Argument type conversion

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

#### Examples

```rust
use fastly::http::Method;

let mut req = Request::get("https://example.com");
req.set_method(Method::POST);
assert_eq!(req.get_method(), &Method::POST);
```

**Parameters**

- `self`: `&mut Self`
- `method`: `impl ToMethod`

### set_pass

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2390

```rust
fn set_pass(&mut self, pass: bool)
```

Set whether this request should be cached if sent to a backend.

By default this is `false`, which means the backend will only be reached if a cached
response is not available. Set this to `true` to send the request directly to the backend
without caching.

#### Overrides

Note that calling [`set_pass(true)`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) will override anything previously set by
[`Request::set_surrogate_key`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl), [`Request::set_pci`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci), and
[`Request::set_stale_while_revalidate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_stale_while_revalidate). If you wish to unconditionally call `set_pass`,
then you may want to instead use the [`CandidateResponse`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/) equivalents of those methods
inside of a [`Request::set_after_send`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send) callback.

Conversely, calling any of those methods on Request *after* calling `set_pass(true)` will
reverse the effect of the `set_pass` call, and any response received when the
request is sent may become cacheable.

**Parameters**

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

### set_path

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2198

```rust
fn set_path(&mut self, path: &str)
```

Set the path component of the request URL.

#### Examples

```rust
let mut req = Request::get("https://example.com/");
req.set_path("/hello");
assert_eq!(req.get_url_str(), "https://example.com/hello");
```

**Parameters**

- `self`: `&mut Self`
- `path`: `&str`

### set_pci

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2472

```rust
fn set_pci(&mut self, pci: bool)
```

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

By default, this is `false`, which means the request 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.

#### Overrides

This overrides any previous [`Request::set_pass`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) call and sets the `pass` behavior to
`false`.

Note that calling [`set_pass(true)`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) will override anything previously set by
[`Request::set_surrogate_key`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl), [`Request::set_pci`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci), and
[`Request::set_stale_while_revalidate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_stale_while_revalidate). If you wish to unconditionally call `set_pass`,
then you may want to instead use the [`CandidateResponse`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/) equivalents of those methods
inside of a [`Request::set_after_send`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send) callback.

Conversely, calling any of those methods on Request *after* calling `set_pass(true)` will
reverse the effect of the `set_pass` call, and any response received when the
request is sent may become cacheable.

**Parameters**

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

### set_query

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2336

```rust
fn set_query(&mut self, query: &impl Serialize) -> Result<(), Error>
```

Convert the given value to `application/x-www-form-urlencoded` format and set that data as
the request URL query component.

The given value must implement [`serde::Serialize`](https://docs.rs/serde_core/1.0.228/serde_core/ser/trait.Serialize.html); see the trait documentation for
details.

#### Errors

This method returns [`serde_urlencoded::ser::Error`](https://docs.rs/serde_urlencoded/latest/serde_urlencoded/ser/enum.Error.html) if serialization fails.

#### Examples

```rust
#[derive(serde::Serialize)]
struct MyData {
    name: String,
    count: u64,
}
let my_data = MyData { name: "Computers".to_string(), count: 1024 };
let mut req = Request::get("https://example.com/foo");
req.set_query(&my_data).unwrap();
assert_eq!(req.get_url_str(), "https://example.com/foo?name=Computers&count=1024");
```

**Parameters**

- `self`: `&mut Self`
- `query`: `&impl Serialize`

**Returns**

`Result<(), serde_urlencoded::ser::Error>`

### set_query_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2299

```rust
fn set_query_str(&mut self, query: impl AsRef<str>)
```

Set the query string of the request URL query component to the given string, performing
percent-encoding if necessary.

#### Examples

```rust
let mut req = Request::get("https://example.com/foo");
req.set_query_str("hello=🌐!&bar=baz");
assert_eq!(req.get_url_str(), "https://example.com/foo?hello=%F0%9F%8C%90!&bar=baz");
```

**Parameters**

- `self`: `&mut Self`
- `query`: `impl AsRef<str>`

### set_stale_if_error

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2440

```rust
fn set_stale_if_error(&mut self, swr: u32)
```

Override the caching behavior of this request to use the given `stale-if-error`
time, in seconds.

#### Overrides

This overrides the behavior specified in the response headers, and will override any
previous [`Request::set_pass`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) call by setting the `pass` behavior to `false`.

Note that calling [`set_pass(true)`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) will override anything previously set by
[`Request::set_surrogate_key`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl), [`Request::set_pci`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci), and
[`Request::set_stale_while_revalidate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_stale_while_revalidate). If you wish to unconditionally call `set_pass`,
then you may want to instead use the [`CandidateResponse`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/) equivalents of those methods
inside of a [`Request::set_after_send`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send) callback.

Conversely, calling any of those methods on Request *after* calling `set_pass(true)` will
reverse the effect of the `set_pass` call, and any response received when the
request is sent may become cacheable.

**Parameters**

- `self`: `&mut Self`
- `swr`: `u32`

### set_stale_while_revalidate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2427

```rust
fn set_stale_while_revalidate(&mut self, swr: u32)
```

Override the caching behavior of this request to use the given `stale-while-revalidate`
time, in seconds.

#### Overrides

This overrides the behavior specified in the response headers, and will override any
previous [`Request::set_pass`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) call by setting the `pass` behavior to `false`.

Note that calling [`set_pass(true)`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) will override anything previously set by
[`Request::set_surrogate_key`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl), [`Request::set_pci`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci), and
[`Request::set_stale_while_revalidate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_stale_while_revalidate). If you wish to unconditionally call `set_pass`,
then you may want to instead use the [`CandidateResponse`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/) equivalents of those methods
inside of a [`Request::set_after_send`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send) callback.

Conversely, calling any of those methods on Request *after* calling `set_pass(true)` will
reverse the effect of the `set_pass` call, and any response received when the
request is sent may become cacheable.

**Parameters**

- `self`: `&mut Self`
- `swr`: `u32`

### set_surrogate_key

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2500

```rust
fn set_surrogate_key(&mut self, sk: HeaderValue)
```

Override the caching behavior of this request to include the given surrogate key(s),
provided as a header value.

The header value can contain more than one surrogate key, separated by spaces.

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.

#### Overrides

This overrides any previous [`Request::set_pass`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) call and sets the `pass` behavior to
`false`, and extends (but does not replace) any `Surrogate-Key` response headers from the
backend.

Note that calling [`set_pass(true)`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) will override anything previously set by
[`Request::set_surrogate_key`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl), [`Request::set_pci`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci), and
[`Request::set_stale_while_revalidate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_stale_while_revalidate). If you wish to unconditionally call `set_pass`,
then you may want to instead use the [`CandidateResponse`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/) equivalents of those methods
inside of a [`Request::set_after_send`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send) callback.

Conversely, calling any of those methods on Request *after* calling `set_pass(true)` will
reverse the effect of the `set_pass` call, and any response received when the
request is sent may become cacheable.

**Parameters**

- `self`: `&mut Self`
- `sk`: `HeaderValue`

### set_ttl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2408

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

Override the caching behavior of this request to use the given Time to Live (TTL), in seconds.

#### Overrides

This overrides any previous [`Request::set_pass`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) call and sets the `pass` behavior to
`false`.

Note that calling [`set_pass(true)`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pass) will override anything previously set by
[`Request::set_surrogate_key`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_surrogate_key), [`Request::set_ttl`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_ttl), [`Request::set_pci`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_pci), and
[`Request::set_stale_while_revalidate`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_stale_while_revalidate). If you wish to unconditionally call `set_pass`,
then you may want to instead use the [`CandidateResponse`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/struct.CandidateResponse/) equivalents of those methods
inside of a [`Request::set_after_send`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_after_send) callback.

Conversely, calling any of those methods on Request *after* calling `set_pass(true)` will
reverse the effect of the `set_pass` call, and any response received when the
request is sent may become cacheable.

**Parameters**

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

### set_url

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2165

```rust
fn set_url(&mut self, url: impl ToUrl)
```

Set the request URL.

#### Argument type conversion

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

**Parameters**

- `self`: `&mut Self`
- `url`: `impl ToUrl`

### set_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2371

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

Set the HTTP version of this request.

**Parameters**

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

### take_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1050

```rust
fn take_body(&mut self) -> Body
```

Take and return the body from this request.

After calling this method, this request will no longer have a body.

An empty body is returned if no body has been set, or if it has previously been returned by a method
like [`take_body()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-take_body).

**Parameters**

- `self`: `&mut Self`

**Returns**

`Body`

### take_body_bytes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1325

```rust
fn take_body_bytes(&mut self) -> Vec<u8>
```

Take and return the body from this request as a string.

After calling this method, this request will no longer have a body.

#### Memory usage

This method will cause the entire body to be buffering in WebAssembly memory. You should take care
not to exceed the WebAssembly memory limits, and consider using methods like
[`read_body_lines()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_lines) or
[`read_body_chunks()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_chunks) to control how much of the body you process at
once.

#### Examples

```rust
let mut req = Request::post("https://example.com").with_body_text_plain("hello, world!");
let bytes = req.take_body_bytes();
assert!(req.try_take_body().is_none());
assert_eq!(&bytes, b"hello, world!");
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`Vec<u8>`

### take_body_form

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1550

```rust
fn take_body_form<T: DeserializeOwned>(&mut self) -> Result<T, Error>
```

Take the request body and attempt to parse it as a `application/x-www-form-urlencoded`
formatted string.

The return type chosen for this function must implement [`serde::de::Deserialize`](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.Deserialize.html) without any
non-static lifetimes; see the trait documentation for details.

After calling this method, this request will no longer have a body.

#### Errors

This method returns [`serde_urlencoded::de::Error`](https://docs.rs/serde_core/1.0.228/serde_core/de/value/struct.Error.html) if deserialization fails.

#### Examples

```rust
#[derive(serde::Deserialize)]
struct MyData {
    name: String,
    count: u64,
}
let mut req = Request::post("https://example.com").with_body("name=Computers&count=1024");
let my_data = req.take_body_form::<MyData>().unwrap();
assert_eq!(&my_data.name, "Computers");
assert_eq!(my_data.count, 1024);
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`Result<T, serde_urlencoded::de::Error>`

### take_body_json

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1466

```rust
fn take_body_json<T: DeserializeOwned>(&mut self) -> Result<T, Error>
```

Take the request body and attempt to parse it as a JSON value.

The return type must implement [`serde::Deserialize`](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.Deserialize.html) without any non-static lifetimes. You
can either implement that trait for your own custom type, or use [`serde_json::Value`](https://docs.rs/serde_json/1.0.145/serde_json/value/enum.Value.html) to
deserialize untyped JSON values. See [`serde_json`](https://docs.rs/serde_json/1.0.145/serde_json/index.html) for details.

After calling this method, this request will no longer have a body.

#### Errors

This method returns [`serde_json::Error`](https://docs.rs/serde_json/1.0.145/serde_json/error/struct.Error.html) if deserialization fails.

#### Examples

Using a type that derives [`serde::de::DeserializeOwned`](https://docs.rs/serde_core/1.0.228/serde_core/de/trait.DeserializeOwned.html):

```rust
#[derive(serde::Deserialize)]
struct MyData {
    name: String,
    count: u64,
}
let mut req = Request::post("https://example.com")
    .with_body(r#"{"name":"Computers","count":1024}"#);
let my_data = req.take_body_json::<MyData>().unwrap();
assert_eq!(&my_data.name, "Computers");
assert_eq!(my_data.count, 1024);
```

Using untyped JSON with [`serde_json::Value`](https://docs.rs/serde_json/1.0.145/serde_json/value/enum.Value.html):

```rust
let my_data = serde_json::json!({
    "name": "Computers",
    "count": 1024,
});
let mut req = Request::post("https://example.com")
    .with_body(r#"{"name":"Computers","count":1024}"#);
let my_data = req.take_body_json::<serde_json::Value>().unwrap();
assert_eq!(my_data["name"].as_str(), Some("Computers"));
assert_eq!(my_data["count"].as_u64(), Some(1024));
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`Result<T, serde_json::Error>`

### take_body_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1230

```rust
fn take_body_str(&mut self) -> String
```

Take and return the body from this request as a string.

After calling this method, this request will no longer have a body.

#### Memory usage

This method will cause the entire body to be buffering in WebAssembly memory. You should take care
not to exceed the WebAssembly memory limits, and consider using methods like
[`read_body_lines()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_lines) or
[`read_body_chunks()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_chunks) to control how much of the body you process at
once.

#### Panics

If the body does not contain a valid UTF-8 string, this function will panic. To handle the
possibility of invalid UTF-8 data, use [`take_body_str_lossy()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-take_body_str_lossy) for
lossy conversion, or use [`take_body_bytes()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-take_body_bytes) and then convert the bytes
with a function like [`String::from_utf8`](https://doc.rust-lang.org/stable/alloc/string/String/fn.from_utf8.html).

#### Examples

```rust
let mut req = Request::post("https://example.com").with_body("hello, world!");
let string = req.take_body_str();
assert!(req.try_take_body().is_none());
assert_eq!(&string, "hello, world!");
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`String`

### take_body_str_lossy

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1256

```rust
fn take_body_str_lossy(&mut self) -> String
```

Take and return the body from this request as a string, including invalid characters.

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

After calling this method, this request will no longer have a body.

#### Memory usage

This method will cause the entire body to be buffering in WebAssembly memory. You should take care
not to exceed the WebAssembly memory limits, and consider using methods like
[`read_body_lines()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_lines) or
[`read_body_chunks()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-read_body_chunks) to control how much of the body you process at
once.

#### Examples

```rust
let mut req = Request::post("https://example.com");
req.set_body_octet_stream(b"\xF0\x90\x80 hello, world!");
let string = req.take_body_str_lossy();
assert!(req.try_take_body().is_none());
assert_eq!(&string, "� hello, world!");
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`String`

### trace

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#515

```rust
fn trace(url: impl ToUrl) -> Self
```

Create a new `TRACE` [`Request`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/) with the given URL, no headers, and an empty body.

#### Argument type conversion

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

**Parameters**

- `url`: `impl ToUrl`

**Returns**

`Self`

### try_get_body_mut

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1000

```rust
fn try_get_body_mut(&mut self) -> Option<&mut Body>
```

Get a shared reference to the body of this request if it has one, otherwise return `None`.

#### Examples

```rust
use std::io::Write;

let mut req = Request::post("https://example.com");
assert!(req.try_get_body_mut().is_none());

req.set_body("hello,");
write!(req.try_get_body_mut().expect("body now exists"), " world!")?;
assert_eq!(&req.into_body_str(), "hello, world!");
```

**Parameters**

- `self`: `&mut Self`

**Returns**

`Option<&mut Body>`

### try_get_body_prefix_str_mut

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1031

```rust
fn try_get_body_prefix_str_mut(&mut self, length: usize) -> Result<PrefixString<'_>, Utf8Error>
```

Try to get a prefix of the body as a string containing up to the given number of bytes.

See [`Body::try_get_prefix_str_mut()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/body/struct.Body/#method-try_get_prefix_str_mut) for details.

**Parameters**

- `self`: `&mut Self`
- `length`: `usize`

**Returns**

`Result<body::PrefixString, std::str::Utf8Error>`

### try_into_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1157

```rust
fn try_into_body(self) -> Option<Body>
```

Consume the request and return its body if it has one, otherwise return `None`.

**Parameters**

- `self`: `Self`

**Returns**

`Option<Body>`

### try_take_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1057

```rust
fn try_take_body(&mut self) -> Option<Body>
```

Take and return the body from this request if it has one, otherwise return `None`.

After calling this method, this request will no longer have a body.

**Parameters**

- `self`: `&mut Self`

**Returns**

`Option<Body>`

### with_after_send

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#556

```rust
fn with_after_send(self, f: impl Fn(&mut CandidateResponse) -> Result<(), SendErrorCause> + Send + Sync + 'static) -> Self
```

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

**Parameters**

- `self`: `Self`
- `f`: `impl Fn(&mut CandidateResponse) -> Result<(), SendErrorCause> + Send + Sync + 'static`

**Returns**

`Self`

### with_auto_decompress_gzip

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2780

```rust
fn with_auto_decompress_gzip(self, gzip: bool) -> Self
```

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

**Parameters**

- `self`: `Self`
- `gzip`: `bool`

**Returns**

`Self`

### with_before_send

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#527

```rust
fn with_before_send(self, f: impl Fn(&mut Request) -> Result<(), SendErrorCause> + Send + Sync + 'static) -> Self
```

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

**Parameters**

- `self`: `Self`
- `f`: `impl Fn(&mut Request) -> Result<(), SendErrorCause> + Send + Sync + 'static`

**Returns**

`Self`

### with_body

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#953

```rust
fn with_body(self, body: impl Into<Body>) -> Self
```

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

**Parameters**

- `self`: `Self`
- `body`: `impl Into<Body>`

**Returns**

`Self`

### with_body_form

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1475

```rust
fn with_body_form(self, value: &impl Serialize) -> Result<Self, Error>
```

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

**Parameters**

- `self`: `Self`
- `value`: `&impl Serialize`

**Returns**

`Result<Self, serde_urlencoded::ser::Error>`

### with_body_json

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1363

```rust
fn with_body_json(self, value: &impl Serialize) -> Result<Self, Error>
```

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

**Parameters**

- `self`: `Self`
- `value`: `&impl Serialize`

**Returns**

`Result<Self, serde_json::Error>`

### with_body_octet_stream

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1286

```rust
fn with_body_octet_stream(self, body: &[u8]) -> Self
```

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

**Parameters**

- `self`: `Self`
- `body`: `&[u8]`

**Returns**

`Self`

### with_body_text_html

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1187

```rust
fn with_body_text_html(self, body: &str) -> Self
```

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

**Parameters**

- `self`: `Self`
- `body`: `&str`

**Returns**

`Self`

### with_body_text_plain

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1162

```rust
fn with_body_text_plain(self, body: &str) -> Self
```

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

**Parameters**

- `self`: `Self`
- `body`: `&str`

**Returns**

`Self`

### with_cache_key

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3075

```rust
fn with_cache_key(self, key: impl Into<Vec<u8>>) -> Self
```

Builder-style equivalent of [`set_cache_key()`](Self::set_cache_key()).

**Parameters**

- `self`: `Self`
- `key`: `impl Into<Vec<u8>>`

**Returns**

`Self`

### with_content_type

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1585

```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/request/struct.Request/#method-set_content_type).

**Parameters**

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

**Returns**

`Self`

### with_framing_headers_mode

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2795

```rust
fn with_framing_headers_mode(self, mode: FramingHeadersMode) -> Self
```

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

**Parameters**

- `self`: `Self`
- `mode`: `FramingHeadersMode`

**Returns**

`Self`

### with_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1633

```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/request/struct.Request/#method-append_header).

**Parameters**

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

**Returns**

`Self`

### with_image_optimizer

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3086

```rust
fn with_image_optimizer(self, options: ImageOptimizerOptions) -> Self
```

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

**Parameters**

- `self`: `Self`
- `options`: `image_optimizer::ImageOptimizerOptions`

**Returns**

`Self`

### with_lookup_timeout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2505

```rust
fn with_lookup_timeout(self, lookup_timeout: Duration) -> Self
```

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

**Parameters**

- `self`: `Self`
- `lookup_timeout`: `std::time::Duration`

**Returns**

`Self`

### with_method

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2055

```rust
fn with_method(self, method: impl ToMethod) -> Self
```

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

**Parameters**

- `self`: `Self`
- `method`: `impl ToMethod`

**Returns**

`Self`

### with_pass

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2376

```rust
fn with_pass(self, pass: bool) -> Self
```

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

**Parameters**

- `self`: `Self`
- `pass`: `bool`

**Returns**

`Self`

### with_path

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2183

```rust
fn with_path(self, path: &str) -> Self
```

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

**Parameters**

- `self`: `Self`
- `path`: `&str`

**Returns**

`Self`

### with_pci

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2451

```rust
fn with_pci(self, pci: bool) -> Self
```

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

**Parameters**

- `self`: `Self`
- `pci`: `bool`

**Returns**

`Self`

### with_query

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2304

```rust
fn with_query(self, query: &impl Serialize) -> Result<Self, Error>
```

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

**Parameters**

- `self`: `Self`
- `query`: `&impl Serialize`

**Returns**

`Result<Self, serde_urlencoded::ser::Error>`

### with_query_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2283

```rust
fn with_query_str(self, query: impl AsRef<str>) -> Self
```

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

**Parameters**

- `self`: `Self`
- `query`: `impl AsRef<str>`

**Returns**

`Self`

### with_set_header

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#1639

```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/request/struct.Request/#method-set_header).

**Parameters**

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

**Returns**

`Self`

### with_stale_if_error

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2445

```rust
fn with_stale_if_error(self, swr: u32) -> Self
```

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

**Parameters**

- `self`: `Self`
- `swr`: `u32`

**Returns**

`Self`

### with_stale_while_revalidate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2413

```rust
fn with_stale_while_revalidate(self, swr: u32) -> Self
```

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

**Parameters**

- `self`: `Self`
- `swr`: `u32`

**Returns**

`Self`

### with_surrogate_key

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2477

```rust
fn with_surrogate_key(self, sk: HeaderValue) -> Self
```

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

**Parameters**

- `self`: `Self`
- `sk`: `HeaderValue`

**Returns**

`Self`

### with_ttl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2395

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

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

**Parameters**

- `self`: `Self`
- `ttl`: `u32`

**Returns**

`Self`

### with_url

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2109

```rust
fn with_url(self, url: impl ToUrl) -> Self
```

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

**Parameters**

- `self`: `Self`
- `url`: `impl ToUrl`

**Returns**

`Self`

### with_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#2360

```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/request/struct.Request/#method-set_version).

**Parameters**

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

**Returns**

`Self`

## Trait implementations

### impl Debug for Request

#### fmt

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#105

```rust
fn fmt(&self, f: &mut Formatter<'_>) -> Result
```

**Parameters**

- `self`: `&Self`
- `f`: `&mut $crate::fmt::Formatter`

**Returns**

`$crate::fmt::Result`

### impl From<Request<Body>> for Request

#### from

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3184

```rust
fn from(from: Request<Body>) -> Self
```

**Parameters**

- `from`: `http::Request<Body>`

**Returns**

`Self`

### impl From<RequestHandle> for Request

#### from

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request.rs#3207

```rust
fn from(handle: RequestHandle) -> Self
```

**Parameters**

- `handle`: `RequestHandle`

**Returns**

`Self`

### impl RequestCacheKey for Request

#### set_cache_key

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#149

```rust
fn set_cache_key(&mut self, key: [u8; 32])
```

Set the cache key to be used when attempting to satisfy this request from a cached response.
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `&mut Self`
- `key`: `[u8; 32]`

#### set_cache_key_fn

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#162

```rust
fn set_cache_key_fn(&mut self, f: impl Fn(&Request) -> [u8; 32] + Send + Sync + 'static)
```

Set the function that will be used to compute the cache key for this request.
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `&mut Self`
- `f`: `impl Fn(&Request) -> [u8; 32] + Send + Sync + 'static`

#### set_cache_key_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#184

```rust
fn set_cache_key_str(&mut self, key_str: impl AsRef<[u8]>)
```

Set a string as the cache key to be used when attempting to satisfy this request from a
cached response.

The string representation of the key is hashed to the same `[u8; 32]` representation used by
[`set_cache_key()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/http/request/struct.Request/#method-set_cache_key).
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `&mut Self`
- `key_str`: `impl AsRef<[u8]>`

#### with_cache_key

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#155

```rust
fn with_cache_key(self, key: [u8; 32]) -> Self
```

Builder-style equivalent of [`set_cache_key()`](Self::set_cache_key()).
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `Self`
- `key`: `[u8; 32]`

**Returns**

`Self`

#### with_cache_key_fn

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#170

```rust
fn with_cache_key_fn(self, f: impl Fn(&Request) -> [u8; 32] + Send + Sync + 'static) -> Self
```

Builder-style equivalent of [`set_cache_key_fn()`](Self::set_cache_key_fn()).
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `Self`
- `f`: `impl Fn(&Request) -> [u8; 32] + Send + Sync + 'static`

**Returns**

`Self`

#### with_cache_key_str

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#194

```rust
fn with_cache_key_str(self, key_str: impl AsRef<[u8]>) -> Self
```

Builder-style equivalent of [`set_cache_key_str()`](Self::set_cache_key_str()).
#### Stability

This is part of an experimental API that is subject to change or removal even in minor versions of
this crate.

**Parameters**

- `self`: `Self`
- `key_str`: `impl AsRef<[u8]>`

**Returns**

`Self`

### impl RequestUpgradeWebsocket for Request

#### handoff_fanout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#282

```rust
fn handoff_fanout(self, backend: &str) -> Result<(), SendError>
```

Pass the request through the Fanout GRIP proxy and on to a backend.

This can only be used on services that have the Fanout feature enabled.

The sending completes in the background. Once this method has been called, no other
response can be sent to this request, and the application can exit without affecting the
send.

**Parameters**

- `self`: `Self`
- `backend`: `&str`

**Returns**

`Result<(), SendError>`

#### handoff_websocket

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/experimental.rs#253

```rust
fn handoff_websocket(self, backend: &str) -> Result<(), SendError>
```

Pass the WebSocket directly to a backend.

This can only be used on services that have the WebSockets feature enabled and on requests
that are valid WebSocket requests.

The sending completes in the background. Once this method has been called, no other
response can be sent to this request, and the application can exit without affecting the
send.

**Parameters**

- `self`: `Self`
- `backend`: `&str`

**Returns**

`Result<(), SendError>`

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