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 "network/public/interfaces/http_message.mojom"; | |
8 import "network/public/interfaces/network_error.mojom"; | |
9 | |
10 struct URLRequest { | |
11 // The URL to load. | |
12 string url; | |
13 | |
14 // The HTTP method if applicable. | |
15 string method = "GET"; | |
16 | |
17 // Additional HTTP request headers. | |
18 array<HttpHeader>? headers; | |
19 | |
20 // The payload for the request body, represented as a concatenation of data | |
21 // streams. For HTTP requests, the method must be set to "POST" or "PUT". | |
22 array<handle<data_pipe_consumer>>? body; | |
23 | |
24 // The buffer size of the data pipe returned in URLResponse's |body| member. | |
25 // A value of 0 indicates that the default buffer size should be used. This | |
26 // value is just a suggestion. The URLLoader may choose to ignore this value. | |
27 uint32 response_body_buffer_size = 0; | |
28 | |
29 // If set to true, then redirects will be automatically followed. Otherwise, | |
30 // when a redirect is encounterd, FollowRedirect must be called to proceed. | |
31 bool auto_follow_redirects = false; | |
32 | |
33 // If set to true, then the HTTP request will bypass the local cache and will | |
34 // have a 'Cache-Control: nocache' header added in that causes any proxy | |
35 // servers to also not satisfy the request from their cache. This has the | |
36 // effect of forcing a full end-to-end fetch. | |
37 bool bypass_cache = false; | |
38 | |
39 // The time when this request originated. 0 indicates that it is not recorded. | |
40 int64 originating_time_ticks = 0; | |
41 }; | |
42 | |
43 struct URLResponse { | |
44 // If the response resulted in a network level error, this field will be set. | |
45 NetworkError? error; | |
46 | |
47 // The response body stream. Read from this data pipe to receive the bytes of | |
48 // response body. | |
49 handle<data_pipe_consumer>? body; | |
50 | |
51 // The final URL of the response, after redirects have been followed. | |
52 string? url; | |
53 | |
54 // The site of the URL. | |
55 string? site; | |
56 | |
57 // The HTTP status code. 0 if not applicable. | |
58 uint32 status_code; | |
59 | |
60 // The HTTP status line. | |
61 string? status_line; | |
62 | |
63 // The HTTP response headers. | |
64 array<HttpHeader>? headers; | |
65 | |
66 // The MIME type of the response body. | |
67 string? mime_type; | |
68 | |
69 // The character set of the response body. | |
70 string? charset; | |
71 | |
72 // These fields are set to non-NULL if this response corresponds to a | |
73 // redirect. Call the |FollowRedirect| method on the URLLoader instance to | |
74 // follow this redirect. | |
75 string? redirect_method; | |
76 string? redirect_url; | |
77 string? redirect_referrer; | |
78 }; | |
79 | |
80 struct URLLoaderStatus { | |
81 // If the loader has failed due to a network level error, this field will be | |
82 // set. | |
83 NetworkError? error; | |
84 | |
85 // Set to true if the URLLoader is still working. Set to false once an error | |
86 // is encountered or the response body is completely copied to the response | |
87 // body stream. | |
88 bool is_loading; | |
89 | |
90 // The length in bytes of the content as reported by the HTTP response header, | |
91 // and the number of bytes read by the URLLoader thus far. | |
92 int64 content_length; | |
93 int64 bytes_read; | |
94 | |
95 // TODO(darin): Add further details about the stages of loading (e.g., | |
96 // "resolving host") that happen prior to receiving bytes. | |
97 }; | |
98 | |
99 interface URLLoader { | |
100 // Loads the given |request|, asynchronously producing |response|. Consult | |
101 // |response| to determine if the request resulted in an error, was | |
102 // redirected, or has a response body to be consumed. | |
103 Start(URLRequest request) => (URLResponse response); | |
104 | |
105 // If the request passed to |Start| had |auto_follow_redirects| set to false, | |
106 // then upon receiving an URLResponse with a non-NULL |redirect_url| field, | |
107 // |FollowRedirect| may be called to load the URL indicated by the redirect. | |
108 FollowRedirect() => (URLResponse response); | |
109 | |
110 // Query status about the URLLoader. | |
111 QueryStatus() => (URLLoaderStatus status); | |
112 }; | |
OLD | NEW |