OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 module mojo; | |
6 | |
7 import "mojo/services/public/interfaces/network/network_error.mojom"; | |
8 | |
9 struct URLRequest { | |
10 // The URL to load. | |
11 string url; | |
12 | |
13 // The HTTP method if applicable. | |
14 string method = "GET"; | |
15 | |
16 // Additional HTTP request headers. | |
17 array<string>? headers; | |
18 | |
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". | |
21 array<handle<data_pipe_consumer>>? body; | |
22 | |
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 | |
25 // |body| to be uploaded using a chunked encoding. | |
26 int64 body_length = 0; | |
27 | |
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 | |
30 // value is just a suggestion. The URLLoader may choose to ignore this value. | |
31 uint32 response_body_buffer_size = 0; | |
32 | |
33 // If set to true, then redirects will be automatically followed. Otherwise, | |
34 // when a redirect is encounterd, FollowRedirect must be called to proceed. | |
35 bool auto_follow_redirects = false; | |
36 | |
37 // If set to true, then the HTTP request will bypass the local cache and will | |
38 // have a 'Cache-Control: nocache' header added in that causes any proxy | |
39 // servers to also not satisfy the request from their cache. This has the | |
40 // effect of forcing a full end-to-end fetch. | |
41 bool bypass_cache = false; | |
42 }; | |
43 | |
44 struct URLResponse { | |
45 // If the response resulted in a network level error, this field will be set. | |
46 NetworkError? error; | |
47 | |
48 // The response body stream. Read from this data pipe to receive the bytes of | |
49 // response body. | |
50 handle<data_pipe_consumer>? body; | |
51 | |
52 // The final URL of the response, after redirects have been followed. | |
53 string? url; | |
54 | |
55 // The HTTP status code. 0 if not applicable. | |
56 uint32 status_code; | |
57 | |
58 // The HTTP status line. | |
59 string? status_line; | |
60 | |
61 // The HTTP response headers. | |
62 array<string>? headers; | |
63 | |
64 // The MIME type of the response body. | |
65 string? mime_type; | |
66 | |
67 // The character set of the response body. | |
68 string? charset; | |
69 | |
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 | |
72 // follow this redirect. | |
73 string? redirect_method; | |
74 string? redirect_url; | |
75 }; | |
76 | |
77 struct URLLoaderStatus { | |
78 // If the loader has failed due to a network level error, this field will be | |
79 // set. | |
80 NetworkError? error; | |
81 | |
82 // Set to true if the URLLoader is still working. Set to false once an error | |
83 // is encountered or the response body is completely copied to the response | |
84 // body stream. | |
85 bool is_loading; | |
86 | |
87 // TODO(darin): Add further details about the stages of loading (e.g., | |
88 // "resolving host") that happen prior to receiving bytes. | |
89 }; | |
90 | |
91 interface URLLoader { | |
92 // Loads the given |request|, asynchronously producing |response|. Consult | |
93 // |response| to determine if the request resulted in an error, was | |
94 // redirected, or has a response body to be consumed. | |
95 Start(URLRequest request) => (URLResponse response); | |
96 | |
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, | |
99 // |FollowRedirect| may be called to load the URL indicated by the redirect. | |
100 FollowRedirect() => (URLResponse response); | |
101 | |
102 // Query status about the URLLoader. | |
103 QueryStatus() => (URLLoaderStatus status); | |
104 }; | |
OLD | NEW |