<br />

Added: 7

## **PROTOCOLS**

## Loader

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=130)*

An HTTP and HTTPS loader.

The loader can service many HTTP or HTTPS requests concurrently. The loader tracks
all the outstanding requests and will cancel them all if the client closes
the loader interface.

<br />

### Fetch

Initiate the given HTTP or HTTPS request, follow redirects, and return the final
response.

The loader will follow redirects (up to an implementation-defined limit)
and return the final response as a reply to this message. To cancel the
request, close the loader interface.

#### Request

| Name | Type |
|---|---|
| `request` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Request` |

#### Response

| Name | Type |
|---|---|
| `response` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Response` |

### Start

Initiate the given HTTP or HTTPS request and return all intermediate responses to
the given client.

Unlike `Fetch`, `Start` does not automatically follow all redirects.
Instead, each individual response along the redirect chain is delivered
to the `LoaderClient`.

#### Request

| Name | Type |
|---|---|
| `request` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Request` |
| `client` | `client_end:https://fuchsia.dev/reference/fidl/fuchsia.net.http#LoaderClient` |

## LoaderClient

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=158)*

A client interface used with `Loader.Start`.

Closing the underlying channel will cancel the associated HTTP transaction.

<br />

### OnResponse

Called by the loader when the loader receives an HTTP response.

If the server has requested a redirect, then `redirect` in `response`
table will describe the target the server requested. To follow the
redirect, reply to this message. To not follow the redirect, close the
underlying channel.

#### Request

| Name | Type |
|---|---|
| `response` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Response` |

#### Response

\<EMPTY\>

## **STRUCTS**

### Header

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=40)*

An HTTP header field.

<br />

| Field | Type | Description | Default |
|---|---|---|---|
| `name` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#HeaderName` | The name of the header field. | No default |
| `value` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#HeaderValue` | The value of the header field. | No default |

## **ENUMS**

### Error [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint32`

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=15)*

An error occurred during the HTTP transaction.

<br />

| Name | Value | Description |
|---|---|---|
| ### INTERNAL | `1` | Some other problem occurred that cannot be classified using one of the more specific statuses. Retry is optional. |
| ### UNABLE_TO_PARSE | `2` | An HTTP parse error. |
| ### CHANNEL_CLOSED | `3` | Indicates a channel (client or body sender) is closed. |
| ### CONNECT | `4` | Error occurred while connecting. |
| ### DEADLINE_EXCEEDED | `5` | The deadline specified in Request has passed |

## **TABLES**

### RedirectTarget

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=88)*

A description of the redirect the server requested.

The semantics of an HTTP redirect vary according to the status code use to
generate the redirect. This structure ensures that the loader and its client
agree on the interpretation of the redirect response from the server.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `method` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Method` | The HTTP method the server suggested for the redirect. |
| ### 2 | `url` | `https://fuchsia.dev/reference/fuchsia.url//https://fuchsia.dev/reference/fuchsia.url#Url` | The URL the server suggested for the redirect. |
| ### 3 | `referrer` | `https://fuchsia.dev/reference/fuchsia.url//https://fuchsia.dev/reference/fuchsia.url#Url` | The referrer the server suggested for the redirect. |

### Request [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=59)*

An HTTP request.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `method` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Method` | The HTTP method if applicable. Defaults to "GET". |
| ### 2 | `url` | `https://fuchsia.dev/reference/fuchsia.url//https://fuchsia.dev/reference/fuchsia.url#Url` | The URL to load. Required. |
| ### 3 | `headers` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.net.http#Header>` | Additional HTTP request headers. |
| ### 4 | `body` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Body` | The payload for the request body. For HTTP requests, the method must be set to "POST" or "PUT". If a buffer is used for the body, a Content-Length header will automatically be added. |
| ### 5 | `deadline` | `https://fuchsia.dev/reference/zx//https://fuchsia.dev/reference/zx#Time` | Determines when to give up on waiting for a response from the server. If no deadline is provided, the implementation will provide a reasonable default. |

### Response [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=100)*

A response to an HTTP request.

<br />

| Ordinal | Field | Type | Description |
|---|---|---|---|
| ### 1 | `error` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#Error` | If the response resulted in a network level error, this field will be set. |
| ### 2 | `body` | `handle<socket>` | The response body. |
| ### 3 | `final_url` | `https://fuchsia.dev/reference/fuchsia.url//https://fuchsia.dev/reference/fuchsia.url#Url` | The final URL of the response, after redirects have been followed. |
| ### 4 | `status_code` | `uint32` | The HTTP status code. |
| ### 5 | `status_line` | `vector<uint8>` | The HTTP status line. |
| ### 6 | `headers` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.net.http#Header>` | The HTTP response headers. |
| ### 7 | `redirect` | `https://fuchsia.dev/reference/fidl/fuchsia.net.http#RedirectTarget` | A description of the redirect the server requested, if any. |

## **UNIONS**

### Body [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible) [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=50)*

The body of an HTTP request.

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `buffer` | `https://fuchsia.dev/reference/fuchsia.mem//https://fuchsia.dev/reference/fuchsia.mem#Buffer` | A buffer that will contain the complete request or response body. |
| ### 2 | `stream` | `handle<socket>` | A socket that will contain the streaming request or response body. |

<br />

## **ALIASES**

| Name | Value | Description |
|---|---|---|
| [HeaderName](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=34) | `vector`\[`https://fuchsia.dev/reference/fidl//https://fuchsia.dev/reference/fidl#MAX`\] | Friendly alias for a vector of bytes containing a header name. |
| [HeaderValue](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=37) | `vector`\[`https://fuchsia.dev/reference/fidl//https://fuchsia.dev/reference/fidl#MAX`\] | Friendly alias for a vector of bytes containing a header value. |
| [Method](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=11) | `string`\[`1024`\] |   |