fuchsia.net.http

PROTOCOLS

Loader

Defined in fuchsia.net.http/client.fidl

An HTTP loader.

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

Fetch

Initiate the given HTTP 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, either close the loader interface or close the peer to the event included in the request.

Request

NameType
request Request

Response

NameType
response Response

Start

Initiate the given HTTP 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

NameType
request Request
client LoaderClient

LoaderClient

Defined in fuchsia.net.http/client.fidl

A client interface used with Loader.Start.

Closing the underlying channel will cancel the associated HTTP transaction.

OnResponse

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

If the server has requested a redirect, then redirect will be non-null and describe the target the server requested. To follow the redirect, reply to this message. To not follow the redirect, close the underlying channel.

Request

NameType
response Response
redirect RedirectTarget?

Response

NameType

STRUCTS

Error

Defined in fuchsia.net.http/client.fidl

An error occurred during the HTTP transaction.

NameTypeDescriptionDefault
code int32 The numerical error code. These error codes correspond to No default
description string? A textual description of the error in en-US. No default

Defined in fuchsia.net.http/client.fidl

An HTTP header field.

NameTypeDescriptionDefault
name vector<uint8> The name of the header field. No default
value vector<uint8> The value of the header field. No default

Request

Defined in fuchsia.net.http/client.fidl

An HTTP request.

NameTypeDescriptionDefault
method string The HTTP method if applicable. GET
url vector<uint8> The URL to load. No default
headers vector<Header>? Additional HTTP request headers. No default
body 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. No default
event handle<eventpair>? The loader will cancel the request if the peer for this event is closed. When this happens, the loader will send a Response with the appropriate error code. No default
cache_mode CacheMode The cache behavior for the request. CacheMode.DEFAULT
response_body_mode ResponseBodyMode The response body mode. ResponseBodyMode.BUFFER

RedirectTarget

Defined in fuchsia.net.http/client.fidl

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.

NameTypeDescriptionDefault
method string The HTTP method the server suggested for the redirect. No default
url vector<uint8> The URL the server suggested for the redirect. No default
referrer vector<uint8> The referrer the server suggested for the redirect. No default

Response

Defined in fuchsia.net.http/client.fidl

A response to an HTTP request.

NameTypeDescriptionDefault
error Error? If the response resulted in a network level error, this field will be set. No default
body Body? The response body. No default
url vector<uint8>? The final URL of the response, after redirects have been followed. No default
status_code uint32 The HTTP status code. 0 if not applicable. No default
status_line string? The HTTP status line. No default
headers vector<Header>? The HTTP response headers. No default
mime_type string? The MIME type of the response body. No default
charset string? The character set of the response body. No default

ENUMS

CacheMode

Type: uint32

Defined in fuchsia.net.http/client.fidl

Specify the cache behavior of the request.

NameValueDescription
DEFAULT 0
BYPASS_CACHE 1
ONLY_FROM_CACHE 2

ResponseBodyMode

Type: uint32

Defined in fuchsia.net.http/client.fidl

Specify the mechanism used to return the response body.

Streaming the response can be more efficient if the response body is large and can be processed incrementally (e.g., by an image decoder).

Buffering the response can be more efficient if the response body is in cache and the cache entry can be directly mapped into the resulting buffer.

NameValueDescription
BUFFER 0
STREAM 1

UNIONS

Body

Defined in fuchsia.net.http/client.fidl

The body of either an HTTP request or an HTTP response.

NameTypeDescription
buffer fuchsia.mem/Buffer A buffer that will contain the complete request or response body.
stream handle<socket> A socket that will contain the streaming request or response body.