| Index: mojo/services/public/interfaces/network/url_loader.mojom
|
| diff --git a/mojo/services/public/interfaces/network/url_loader.mojom b/mojo/services/public/interfaces/network/url_loader.mojom
|
| index 22d5fdb5c7a3decf1cf54c96c75a3dd2de82b359..da340c4cf0226b75c0dd095300385c5f2de7f8f5 100644
|
| --- a/mojo/services/public/interfaces/network/url_loader.mojom
|
| +++ b/mojo/services/public/interfaces/network/url_loader.mojom
|
| @@ -16,15 +16,20 @@ struct URLRequest {
|
| // Additional HTTP request headers.
|
| string[] headers;
|
|
|
| - // The payload for the request body. For HTTP requests, the method must be
|
| - // set to "POST" or "PUT".
|
| - handle<data_pipe_consumer> body;
|
| + // The payload for the request body, represented as a concatenation of data
|
| + // streams. For HTTP requests, the method must be set to "POST" or "PUT".
|
| + handle<data_pipe_consumer>[] body;
|
|
|
| // The number of bytes to be read from |body|. A Content-Length header of
|
| // this value will be sent. Set to -1 if length is unknown, which will cause
|
| // |body| to be uploaded using a chunked encoding.
|
| int64 body_length = 0;
|
|
|
| + // The buffer size of the data pipe returned in URLResponse's |body| member.
|
| + // A value of 0 indicates that the default buffer size should be used. This
|
| + // value is just a suggestion. The URLLoader may choose to ignore this value.
|
| + uint32 response_body_buffer_size = 0;
|
| +
|
| // If set to true, then redirects will be automatically followed. Otherwise,
|
| // when a redirect is encounterd, FollowRedirect must be called to proceed.
|
| bool auto_follow_redirects = false;
|
| @@ -37,6 +42,13 @@ struct URLRequest {
|
| };
|
|
|
| struct URLResponse {
|
| + // If the response resulted in a network level error, this field will be set.
|
| + NetworkError error;
|
| +
|
| + // The response body stream. Read from this data pipe to receive the bytes of
|
| + // response body.
|
| + handle<data_pipe_consumer> body;
|
| +
|
| // The final URL of the response, after redirects have been followed.
|
| string url;
|
|
|
| @@ -54,47 +66,41 @@ struct URLResponse {
|
|
|
| // The character set of the response body.
|
| string charset;
|
| +
|
| + // These fields are set to non-NULL if this response corresponds to a
|
| + // redirect. Call the |FollowRedirect| method on the URLLoader instance to
|
| + // follow this redirect.
|
| + string redirect_method;
|
| + string redirect_url;
|
| +};
|
| +
|
| +struct URLLoaderStatus {
|
| + // If the loader has failed due to a network level error, this field will be
|
| + // set.
|
| + NetworkError 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.
|
| };
|
|
|
| -[Client=URLLoaderClient]
|
| interface URLLoader {
|
| - // Start loading the given |request|. When available, the response body will
|
| - // be copied to |response_body_stream|.
|
| - //
|
| - // The client's |OnReceivedResponse| method will run when response meta data
|
| - // becomes available, or if a redirect response is encountered and
|
| - // |auto_follow_redirects| is false, the client's |OnRecievedRedirect| method
|
| - // will called instead.
|
| - //
|
| - // NOTE: You may observe data being pushed to |response_body_stream| before
|
| - // you receive |OnReceivedResponse|.
|
| - Start(URLRequest request, handle<data_pipe_producer> response_body_stream);
|
| + // 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 a redirect, |OnReceivedRedirect| will be called. To
|
| - // follow the indicated redirect, call the |FollowRedirect| method.
|
| - FollowRedirect();
|
| -};
|
| + // 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);
|
|
|
| -interface URLLoaderClient {
|
| - // This method is called when a redirect is encountered, provided the
|
| - // request's |auto_follow_redirects| attribute was set to false.
|
| - OnReceivedRedirect(URLResponse response, string new_url, string new_method);
|
| -
|
| - // This method is called when response meta data becomes available.
|
| - OnReceivedResponse(URLResponse response);
|
| -
|
| - // This method is called when a network level error is encountered. This can
|
| - // happen before or after OnReceivedResponse, but cannot happen after
|
| - // OnReceivedEndOfResponseBody.
|
| - OnReceivedError(NetworkError error);
|
| -
|
| - // This method is called when the response body has been successfully
|
| - // downloaded and copied in its entirety to |response_body_stream|.
|
| - //
|
| - // NOTE: Because |response_body_stream| is limited in size, this event may be
|
| - // delayed until |response_body_stream| is consumed.
|
| - OnReceivedEndOfResponseBody();
|
| + // Query status about the URLLoader.
|
| + QueryStatus() => (URLLoaderStatus status);
|
| };
|
|
|
| }
|
|
|