OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 module mojo; | 5 module mojo; |
6 | 6 |
7 import "mojo/services/public/interfaces/network/network_error.mojom"; | 7 import "mojo/services/public/interfaces/network/network_error.mojom"; |
8 | 8 |
9 struct URLRequest { | 9 struct URLRequest { |
10 // The URL to load. | 10 // The URL to load. |
11 string? url; | 11 string url; |
12 | 12 |
13 // The HTTP method if applicable. | 13 // The HTTP method if applicable. |
14 string? method = "GET"; | 14 string method = "GET"; |
15 | 15 |
16 // Additional HTTP request headers. | 16 // Additional HTTP request headers. |
17 array<string?>? headers; | 17 array<string>? headers; |
18 | 18 |
19 // The payload for the request body, represented as a concatenation of data | 19 // The payload for the request body, represented as a concatenation of data |
20 // streams. For HTTP requests, the method must be set to "POST" or "PUT". | 20 // streams. For HTTP requests, the method must be set to "POST" or "PUT". |
21 array<handle<data_pipe_consumer>?>? body; | 21 array<handle<data_pipe_consumer>>? body; |
22 | 22 |
23 // The number of bytes to be read from |body|. A Content-Length header of | 23 // The number of bytes to be read from |body|. A Content-Length header of |
24 // this value will be sent. Set to -1 if length is unknown, which will cause | 24 // this value will be sent. Set to -1 if length is unknown, which will cause |
25 // |body| to be uploaded using a chunked encoding. | 25 // |body| to be uploaded using a chunked encoding. |
26 int64 body_length = 0; | 26 int64 body_length = 0; |
27 | 27 |
28 // The buffer size of the data pipe returned in URLResponse's |body| member. | 28 // The buffer size of the data pipe returned in URLResponse's |body| member. |
29 // A value of 0 indicates that the default buffer size should be used. This | 29 // A value of 0 indicates that the default buffer size should be used. This |
30 // value is just a suggestion. The URLLoader may choose to ignore this value. | 30 // value is just a suggestion. The URLLoader may choose to ignore this value. |
31 uint32 response_body_buffer_size = 0; | 31 uint32 response_body_buffer_size = 0; |
(...skipping 20 matching lines...) Expand all Loading... |
52 // The final URL of the response, after redirects have been followed. | 52 // The final URL of the response, after redirects have been followed. |
53 string? url; | 53 string? url; |
54 | 54 |
55 // The HTTP status code. 0 if not applicable. | 55 // The HTTP status code. 0 if not applicable. |
56 uint32 status_code; | 56 uint32 status_code; |
57 | 57 |
58 // The HTTP status line. | 58 // The HTTP status line. |
59 string? status_line; | 59 string? status_line; |
60 | 60 |
61 // The HTTP response headers. | 61 // The HTTP response headers. |
62 array<string?>? headers; | 62 array<string>? headers; |
63 | 63 |
64 // The MIME type of the response body. | 64 // The MIME type of the response body. |
65 string? mime_type; | 65 string? mime_type; |
66 | 66 |
67 // The character set of the response body. | 67 // The character set of the response body. |
68 string? charset; | 68 string? charset; |
69 | 69 |
70 // These fields are set to non-NULL if this response corresponds to a | 70 // These fields are set to non-NULL if this response corresponds to a |
71 // redirect. Call the |FollowRedirect| method on the URLLoader instance to | 71 // redirect. Call the |FollowRedirect| method on the URLLoader instance to |
72 // follow this redirect. | 72 // follow this redirect. |
(...skipping 12 matching lines...) Expand all Loading... |
85 bool is_loading; | 85 bool is_loading; |
86 | 86 |
87 // TODO(darin): Add further details about the stages of loading (e.g., | 87 // TODO(darin): Add further details about the stages of loading (e.g., |
88 // "resolving host") that happen prior to receiving bytes. | 88 // "resolving host") that happen prior to receiving bytes. |
89 }; | 89 }; |
90 | 90 |
91 interface URLLoader { | 91 interface URLLoader { |
92 // Loads the given |request|, asynchronously producing |response|. Consult | 92 // Loads the given |request|, asynchronously producing |response|. Consult |
93 // |response| to determine if the request resulted in an error, was | 93 // |response| to determine if the request resulted in an error, was |
94 // redirected, or has a response body to be consumed. | 94 // redirected, or has a response body to be consumed. |
95 Start(URLRequest? request) => (URLResponse? response); | 95 Start(URLRequest request) => (URLResponse response); |
96 | 96 |
97 // If the request passed to |Start| had |auto_follow_redirects| set to false, | 97 // If the request passed to |Start| had |auto_follow_redirects| set to false, |
98 // then upon receiving an URLResponse with a non-NULL |redirect_url| field, | 98 // then upon receiving an URLResponse with a non-NULL |redirect_url| field, |
99 // |FollowRedirect| may be called to load the URL indicated by the redirect. | 99 // |FollowRedirect| may be called to load the URL indicated by the redirect. |
100 FollowRedirect() => (URLResponse? response); | 100 FollowRedirect() => (URLResponse response); |
101 | 101 |
102 // Query status about the URLLoader. | 102 // Query status about the URLLoader. |
103 QueryStatus() => (URLLoaderStatus? status); | 103 QueryStatus() => (URLLoaderStatus status); |
104 }; | 104 }; |
OLD | NEW |