|  | // 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; | 
|  |  | 
|  | struct URLLoaderStatus { | 
|  | /// If the loader has failed due to a network level error, this field will be | 
|  | /// set. | 
|  | HttpError? error; | 
|  |  | 
|  | /// 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. | 
|  | bool is_loading; | 
|  |  | 
|  | // 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(URLRequest request) -> (URLResponse response); | 
|  |  | 
|  | /// 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() -> (URLResponse response); | 
|  |  | 
|  | /// Query status about the URLLoader. | 
|  | QueryStatus() -> (URLLoaderStatus status); | 
|  | }; |