| <link rel="stylesheet" href="../style.css" /> |
| |
| [TOC] |
| # fuchsia.net.http |
| |
| <div class="fidl-version-div"><span class="fidl-attribute fidl-version">Added: 7</span></div> |
| |
| |
| ## **PROTOCOLS** |
| |
| ## Loader {#Loader} |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=122)* |
| <p>An HTTP and HTTPS loader.</p> |
| <p>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.</p> |
| |
| |
| ### Fetch {#Loader.Fetch} |
| |
| <p>Initiate the given HTTP or HTTPS request, follow redirects, and return the final |
| response.</p> |
| <p>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 |
| <code>event</code> included in the <code>request</code>.</p> |
| |
| |
| |
| #### Request {#Loader.Fetch_Request} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>request</code></td> |
| <td> |
| <code><a class='link' href='#Request'>Request</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| #### Response {#Loader.Fetch_Response} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>response</code></td> |
| <td> |
| <code><a class='link' href='#Response'>Response</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| ### Start {#Loader.Start} |
| |
| <p>Initiate the given HTTP or HTTPS request and return all intermediate responses to |
| the given client.</p> |
| <p>Unlike <code>Fetch</code>, <code>Start</code> does not automatically follow all redirects. |
| Instead, each individual response along the redirect chain is delivered |
| to the <code>LoaderClient</code>.</p> |
| |
| |
| |
| #### Request {#Loader.Start_Request} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>request</code></td> |
| <td> |
| <code><a class='link' href='#Request'>Request</a></code> |
| </td> |
| </tr> |
| <tr> |
| <td><code>client</code></td> |
| <td> |
| <code><a class='link' href='#LoaderClient'>LoaderClient</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| ## LoaderClient {#LoaderClient} |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=151)* |
| <p>A client interface used with <code>Loader.Start</code>.</p> |
| <p>Closing the underlying channel will cancel the associated HTTP transaction.</p> |
| |
| |
| ### OnResponse {#LoaderClient.OnResponse} |
| |
| <p>Called by the loader when the loader receives an HTTP response.</p> |
| <p>If the server has requested a redirect, then <code>redirect</code> in <code>response</code> |
| 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.</p> |
| |
| |
| |
| #### Request {#LoaderClient.OnResponse_Request} |
| |
| <table> |
| <tr><th>Name</th><th>Type</th></tr> |
| <tr> |
| <td><code>response</code></td> |
| <td> |
| <code><a class='link' href='#Response'>Response</a></code> |
| </td> |
| </tr> |
| </table> |
| |
| |
| #### Response {#LoaderClient.OnResponse_Response} |
| |
| <EMPTY> |
| |
| |
| ## **STRUCTS** |
| |
| ### Header {#Header data-text="Header"} |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=33)* |
| <p>An HTTP header field.</p> |
| |
| <table> |
| <tr><th>Field</th><th>Type</th><th>Description</th><th>Default</th></tr> |
| <tr id="Header.name"> |
| <td><code>name</code></td> |
| <td> |
| <code>vector<uint8></code> |
| </td> |
| <td><p>The name of the header field.</p> |
| </td> |
| <td>No default</td> |
| </tr> |
| <tr id="Header.value"> |
| <td><code>value</code></td> |
| <td> |
| <code>vector<uint8></code> |
| </td> |
| <td><p>The value of the header field.</p> |
| </td> |
| <td>No default</td> |
| </tr> |
| </table> |
| |
| |
| ## **ENUMS** |
| |
| ### Error [strict](/fuchsia-src/reference/fidl/language/language.md#strict-vs-flexible){:.fidl-attribute} {#Error data-text="Error"} |
| Type: <code>uint32</code> |
| |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=14)* |
| <p>An error occurred during the HTTP transaction.</p> |
| |
| <table> |
| <tr><th>Name</th><th>Value</th><th>Description</th></tr> |
| <tr id="Error.INTERNAL"> |
| <td><h3 id="Error.INTERNAL" class="add-link hide-from-toc">INTERNAL</h3></td> |
| <td><code>1</code></td> |
| <td><p>Some other problem occurred that cannot be classified using one of the |
| more specific statuses. Retry is optional.</p> |
| </td> |
| </tr> |
| <tr id="Error.UNABLE_TO_PARSE"> |
| <td><h3 id="Error.UNABLE_TO_PARSE" class="add-link hide-from-toc">UNABLE_TO_PARSE</h3></td> |
| <td><code>2</code></td> |
| <td><p>An HTTP parse error.</p> |
| </td> |
| </tr> |
| <tr id="Error.CHANNEL_CLOSED"> |
| <td><h3 id="Error.CHANNEL_CLOSED" class="add-link hide-from-toc">CHANNEL_CLOSED</h3></td> |
| <td><code>3</code></td> |
| <td><p>Indicates a channel (client or body sender) is closed.</p> |
| </td> |
| </tr> |
| <tr id="Error.CONNECT"> |
| <td><h3 id="Error.CONNECT" class="add-link hide-from-toc">CONNECT</h3></td> |
| <td><code>4</code></td> |
| <td><p>Error occurred while connecting.</p> |
| </td> |
| </tr> |
| <tr id="Error.DEADLINE_EXCEEDED"> |
| <td><h3 id="Error.DEADLINE_EXCEEDED" class="add-link hide-from-toc">DEADLINE_EXCEEDED</h3></td> |
| <td><code>5</code></td> |
| <td><p>The deadline specified in Request has passed</p> |
| </td> |
| </tr> |
| </table> |
| |
| |
| ## **TABLES** |
| |
| ### RedirectTarget {#RedirectTarget data-text="RedirectTarget"} |
| |
| |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=80)* |
| <p>A description of the redirect the server requested.</p> |
| <p>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.</p> |
| |
| <table> |
| <tr><th>Ordinal</th><th>Field</th><th>Type</th><th>Description</th></tr> |
| <tr id="RedirectTarget.method"> |
| <td><h3 id="RedirectTarget.method" class="add-link hide-from-toc">1</h3></td> |
| <td><code>method</code></td> |
| <td> |
| <code><a class='link' href='#Method'>Method</a></code> |
| </td> |
| <td><p>The HTTP method the server suggested for the redirect.</p> |
| </td> |
| </tr> |
| <tr id="RedirectTarget.url"> |
| <td><h3 id="RedirectTarget.url" class="add-link hide-from-toc">2</h3></td> |
| <td><code>url</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.url/'>fuchsia.url</a>/<a class='link' href='../fuchsia.url/#Url'>Url</a></code> |
| </td> |
| <td><p>The URL the server suggested for the redirect.</p> |
| </td> |
| </tr> |
| <tr id="RedirectTarget.referrer"> |
| <td><h3 id="RedirectTarget.referrer" class="add-link hide-from-toc">3</h3></td> |
| <td><code>referrer</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.url/'>fuchsia.url</a>/<a class='link' href='../fuchsia.url/#Url'>Url</a></code> |
| </td> |
| <td><p>The referrer the server suggested for the redirect.</p> |
| </td> |
| </tr> |
| </table> |
| |
| ### Request [resource](/fuchsia-src/reference/fidl/language/language.md#value-vs-resource){:.fidl-attribute} {#Request data-text="Request"} |
| |
| |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=51)* |
| <p>An HTTP request.</p> |
| |
| <table> |
| <tr><th>Ordinal</th><th>Field</th><th>Type</th><th>Description</th></tr> |
| <tr id="Request.method"> |
| <td><h3 id="Request.method" class="add-link hide-from-toc">1</h3></td> |
| <td><code>method</code></td> |
| <td> |
| <code><a class='link' href='#Method'>Method</a></code> |
| </td> |
| <td><p>The HTTP method if applicable.</p> |
| <p>Defaults to "GET".</p> |
| </td> |
| </tr> |
| <tr id="Request.url"> |
| <td><h3 id="Request.url" class="add-link hide-from-toc">2</h3></td> |
| <td><code>url</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.url/'>fuchsia.url</a>/<a class='link' href='../fuchsia.url/#Url'>Url</a></code> |
| </td> |
| <td><p>The URL to load.</p> |
| <p>Required.</p> |
| </td> |
| </tr> |
| <tr id="Request.headers"> |
| <td><h3 id="Request.headers" class="add-link hide-from-toc">3</h3></td> |
| <td><code>headers</code></td> |
| <td> |
| <code>vector<<a class='link' href='#Header'>Header</a>></code> |
| </td> |
| <td><p>Additional HTTP request headers.</p> |
| </td> |
| </tr> |
| <tr id="Request.body"> |
| <td><h3 id="Request.body" class="add-link hide-from-toc">4</h3></td> |
| <td><code>body</code></td> |
| <td> |
| <code><a class='link' href='#Body'>Body</a></code> |
| </td> |
| <td><p>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.</p> |
| </td> |
| </tr> |
| <tr id="Request.deadline"> |
| <td><h3 id="Request.deadline" class="add-link hide-from-toc">5</h3></td> |
| <td><code>deadline</code></td> |
| <td> |
| <code><a class='link' href='../zx/'>zx</a>/<a class='link' href='../zx/#time'>time</a></code> |
| </td> |
| <td><p>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.</p> |
| </td> |
| </tr> |
| </table> |
| |
| ### Response [resource](/fuchsia-src/reference/fidl/language/language.md#value-vs-resource){:.fidl-attribute} {#Response data-text="Response"} |
| |
| |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=92)* |
| <p>A response to an HTTP request.</p> |
| |
| <table> |
| <tr><th>Ordinal</th><th>Field</th><th>Type</th><th>Description</th></tr> |
| <tr id="Response.error"> |
| <td><h3 id="Response.error" class="add-link hide-from-toc">1</h3></td> |
| <td><code>error</code></td> |
| <td> |
| <code><a class='link' href='#Error'>Error</a></code> |
| </td> |
| <td><p>If the response resulted in a network level error, this field will be |
| set.</p> |
| </td> |
| </tr> |
| <tr id="Response.body"> |
| <td><h3 id="Response.body" class="add-link hide-from-toc">2</h3></td> |
| <td><code>body</code></td> |
| <td> |
| <code>handle<socket></code> |
| </td> |
| <td><p>The response body.</p> |
| </td> |
| </tr> |
| <tr id="Response.final_url"> |
| <td><h3 id="Response.final_url" class="add-link hide-from-toc">3</h3></td> |
| <td><code>final_url</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.url/'>fuchsia.url</a>/<a class='link' href='../fuchsia.url/#Url'>Url</a></code> |
| </td> |
| <td><p>The final URL of the response, after redirects have been followed.</p> |
| </td> |
| </tr> |
| <tr id="Response.status_code"> |
| <td><h3 id="Response.status_code" class="add-link hide-from-toc">4</h3></td> |
| <td><code>status_code</code></td> |
| <td> |
| <code>uint32</code> |
| </td> |
| <td><p>The HTTP status code.</p> |
| </td> |
| </tr> |
| <tr id="Response.status_line"> |
| <td><h3 id="Response.status_line" class="add-link hide-from-toc">5</h3></td> |
| <td><code>status_line</code></td> |
| <td> |
| <code>vector<uint8></code> |
| </td> |
| <td><p>The HTTP status line.</p> |
| </td> |
| </tr> |
| <tr id="Response.headers"> |
| <td><h3 id="Response.headers" class="add-link hide-from-toc">6</h3></td> |
| <td><code>headers</code></td> |
| <td> |
| <code>vector<<a class='link' href='#Header'>Header</a>></code> |
| </td> |
| <td><p>The HTTP response headers.</p> |
| </td> |
| </tr> |
| <tr id="Response.redirect"> |
| <td><h3 id="Response.redirect" class="add-link hide-from-toc">7</h3></td> |
| <td><code>redirect</code></td> |
| <td> |
| <code><a class='link' href='#RedirectTarget'>RedirectTarget</a></code> |
| </td> |
| <td><p>A description of the redirect the server requested, if any.</p> |
| </td> |
| </tr> |
| </table> |
| |
| |
| ## **UNIONS** |
| |
| ### Body [strict](/fuchsia-src/reference/fidl/language/language.md#strict-vs-flexible){:.fidl-attribute} [resource](/fuchsia-src/reference/fidl/language/language.md#value-vs-resource){:.fidl-attribute} {#Body data-text="Body"} |
| *Defined in [fuchsia.net.http/client.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=42)* |
| <p>The body of an HTTP request.</p> |
| <table> |
| <tr><th>Ordinal</th><th>Variant</th><th>Type</th><th>Description</th></tr> |
| <tr id="Body.buffer"> |
| <td><h3 id="Body.buffer" class="add-link hide-from-toc">1</h3></td> |
| <td><code>buffer</code></td> |
| <td> |
| <code><a class='link' href='../fuchsia.mem/'>fuchsia.mem</a>/<a class='link' href='../fuchsia.mem/#Buffer'>Buffer</a></code> |
| </td> |
| <td><p>A buffer that will contain the complete request or response body.</p> |
| </td> |
| </tr> |
| <tr id="Body.stream"> |
| <td><h3 id="Body.stream" class="add-link hide-from-toc">2</h3></td> |
| <td><code>stream</code></td> |
| <td> |
| <code>handle<socket></code> |
| </td> |
| <td><p>A socket that will contain the streaming request or response body.</p> |
| </td> |
| </tr> |
| </table> |
| |
| |
| |
| |
| ## **ALIASES** |
| |
| <table> |
| <tr><th>Name</th><th>Value</th><th>Description</th></tr> |
| <tr id="Method"> |
| <td><a href="https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.net.http/client.fidl;l=11">Method</a></td> |
| <td> |
| <code>string</code>[<code>1024</code>]</td> |
| <td></td> |
| </tr> |
| </table> |