| // Copyright 2015 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.net.oldhttp; |
| |
| type URLLoaderStatus = struct { |
| /// If the loader has failed due to a network level error, this field will be |
| /// set. |
| error box<HttpError>; |
| |
| /// Set to true if the URLLoader is still working. Set to false once an error |
| /// is encountered or the response body is completely copied to the response |
| /// body stream. |
| is_loading bool; |
| |
| // TODO(darin): Add further details about the stages of loading (e.g., |
| // "resolving host") that happen prior to receiving bytes. |
| }; |
| |
| protocol URLLoader { |
| /// Loads the given `request`, asynchronously producing `response`. Consult |
| /// `response` to determine if the request resulted in an error, was |
| /// redirected, or has a response body to be consumed. |
| Start(resource struct { |
| request URLRequest; |
| }) -> (resource struct { |
| response URLResponse; |
| }); |
| |
| /// If the request passed to `Start` had `auto_follow_redirects` set to false, |
| /// then upon receiving an URLResponse with a non-NULL `redirect_url` field, |
| /// `FollowRedirect` may be called to load the URL indicated by the redirect. |
| FollowRedirect() -> (resource struct { |
| response URLResponse; |
| }); |
| |
| /// Query status about the URLLoader. |
| QueryStatus() -> (struct { |
| status URLLoaderStatus; |
| }); |
| }; |