Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: mojo/services/public/interfaces/network/url_loader.mojom

Issue 324023002: Mojo: cleanup redirect handling for network service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « mojo/services/network/url_loader_impl.cc ('k') | mojo/shell/dynamic_service_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import "network_error.mojom" 5 import "network_error.mojom"
6 6
7 module mojo { 7 module mojo {
8 8
9 struct URLRequest { 9 struct URLRequest {
10 // The URL to load.
10 string url; 11 string url;
12
13 // The HTTP method if applicable.
11 string method = "GET"; 14 string method = "GET";
15
16 // Additional HTTP request headers.
12 string[] headers; 17 string[] headers;
18
19 // The payload for the request body. For HTTP requests, the method must be
20 // set to "POST" or "PUT".
13 handle<data_pipe_consumer> body; 21 handle<data_pipe_consumer> body;
14 int64 body_length = 0; // Set to -1 if length is unknown. 22
15 bool follow_redirects = false; 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 // If set to true, then redirects will be automatically followed. Otherwise,
29 // when a redirect is encounterd, FollowRedirect must be called to proceed.
30 bool auto_follow_redirects = false;
31
32 // If set to true, then the HTTP request will bypass the local cache and will
33 // have a 'Cache-Control: nocache' header added in that causes any proxy
34 // servers to also not satisfy the request from their cache. This has the
35 // effect of forcing a full end-to-end fetch.
16 bool bypass_cache = false; 36 bool bypass_cache = false;
17 }; 37 };
18 38
19 struct URLResponse { 39 struct URLResponse {
40 // The final URL of the response, after redirects have been followed.
20 string url; 41 string url;
21 string[] redirects; // The sequence of redirected URLs. 42
43 // The HTTP status code. 0 if not applicable.
22 uint32 status_code; 44 uint32 status_code;
45
46 // The HTTP status line.
23 string status_line; 47 string status_line;
48
49 // The HTTP response headers.
24 string[] headers; 50 string[] headers;
25 }; 51 };
26 52
27 [Client=URLLoaderClient] 53 [Client=URLLoaderClient]
28 interface URLLoader { 54 interface URLLoader {
29 // Start loading the given |request|. When available, the response body will 55 // Start loading the given |request|. When available, the response body will
30 // be copied to |response_body_stream|. 56 // be copied to |response_body_stream|.
31 // 57 //
32 // The client's |OnReceivedResponse| method will run when response meta data 58 // The client's |OnReceivedResponse| method will run when response meta data
33 // becomes available, or if a redirect is encountered and |follow_redirects| 59 // becomes available, or if a redirect response is encountered and
34 // is false, the client's |OnRecievedRedirect| method will called. 60 // |auto_follow_redirects| is false, the client's |OnRecievedRedirect| method
61 // will called instead.
35 // 62 //
36 // NOTE: You may observe data being pushed to |response_body_stream| before 63 // NOTE: You may observe data being pushed to |response_body_stream| before
37 // you receive |OnReceivedResponse|. 64 // you receive |OnReceivedResponse|.
38 Start(URLRequest request, handle<data_pipe_producer> response_body_stream); 65 Start(URLRequest request, handle<data_pipe_producer> response_body_stream);
39 66
40 // If the request passed to |Start| was configured with |follow_redirects| 67 // If the request passed to |Start| had |auto_follow_redirects| set to false,
41 // set to false, then upon receiving a redirect, |OnReceivedRedirect| will be 68 // then upon receiving a redirect, |OnReceivedRedirect| will be called. To
42 // called. To follow the indicated redirect, call the |FollowRedirect| 69 // follow the indicated redirect, call the |FollowRedirect| method.
43 // method.
44 FollowRedirect(); 70 FollowRedirect();
45 }; 71 };
46 72
47 interface URLLoaderClient { 73 interface URLLoaderClient {
48 // This method is called when a redirect is encountered, provided the 74 // This method is called when a redirect is encountered, provided the
49 // request's |follow_redirects| attribute was set to false. 75 // request's |auto_follow_redirects| attribute was set to false.
50 OnReceivedRedirect(URLResponse response, string new_url, string new_method); 76 OnReceivedRedirect(URLResponse response, string new_url, string new_method);
51 77
52 // This method is called when response meta data becomes available. 78 // This method is called when response meta data becomes available.
53 OnReceivedResponse(URLResponse response); 79 OnReceivedResponse(URLResponse response);
54 80
55 // This method is called when a network level error is encountered. This can 81 // This method is called when a network level error is encountered. This can
56 // happen before or after OnReceivedResponse, but cannot happen after 82 // happen before or after OnReceivedResponse, but cannot happen after
57 // OnReceivedEndOfResponseBody. 83 // OnReceivedEndOfResponseBody.
58 OnReceivedError(NetworkError error); 84 OnReceivedError(NetworkError error);
59 85
60 // This method is called when the response body has been successfully 86 // This method is called when the response body has been successfully
61 // downloaded and copied in its entirety to |response_body_stream|. 87 // downloaded and copied in its entirety to |response_body_stream|.
62 // 88 //
63 // NOTE: Because |response_body_stream| is limited in size, this event may be 89 // NOTE: Because |response_body_stream| is limited in size, this event may be
64 // delayed until |response_body_stream| is consumed. 90 // delayed until |response_body_stream| is consumed.
65 OnReceivedEndOfResponseBody(); 91 OnReceivedEndOfResponseBody();
66 }; 92 };
67 93
68 } 94 }
OLDNEW
« no previous file with comments | « mojo/services/network/url_loader_impl.cc ('k') | mojo/shell/dynamic_service_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698