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 package org.chromium.net; | |
6 | |
7 /** | |
8 * HTTP request (GET, PUT or POST). | |
9 * Note: All methods must be called on the Executor passed in during creation. | |
10 */ | |
11 public abstract interface AsyncUrlRequest { | |
12 /** | |
13 * More setters go here. They may only be called before start (Maybe | |
14 * also allow during redirects). Could optionally instead use arguments | |
15 * to URLRequestFactory when creating the request. | |
16 */ | |
17 | |
18 /** | |
19 * Sets the HTTP method verb to use for this request. | |
20 * | |
21 * <p>The default when this method is not called is "GET" if the request has | |
22 * no body or "POST" if it does. | |
23 * | |
24 * @param method Either "POST" or "PUT". | |
25 */ | |
26 public void setHttpMethod(String method); | |
27 | |
28 /** | |
29 * Adds a request header. Must be done before request has started. | |
30 * | |
31 * @param header Header name | |
32 * @param value Header value | |
33 */ | |
34 public void addHeader(String header, String value); | |
35 | |
36 /** | |
37 * Starts the request, all callbacks go to listener. | |
38 * @param listener | |
39 */ | |
40 public void start(AsyncUrlRequestListener listener); | |
41 | |
42 /** | |
43 * Can be called at any time. | |
44 */ | |
45 public void cancel(); | |
46 | |
47 /** | |
48 * | |
49 * @return True if the request has been cancelled by the embedder. | |
50 * TBD(mmenke): False in all other cases (Including errors). | |
51 */ | |
52 public boolean isCanceled(); | |
53 | |
54 /** | |
55 * Can be called at any time, but the request may continue behind the | |
56 * scenes, depending on when it's called. None of the listener's methods | |
57 * will be called while paused, until and unless the request is resumed. | |
58 * (Note: This allows us to have more than one ByteBuffer in flight, | |
59 * if we want, as well as allow pausing at any point). | |
60 * | |
61 * TBD: May need different pause behavior. | |
62 */ | |
63 public void pause(); | |
64 | |
65 /** | |
66 * Returns True if paused. False if not paused or is cancelled. | |
67 * @return | |
68 */ | |
69 public boolean isPaused(); | |
70 | |
71 /** | |
72 * When resuming, any pending callback to the listener will be called | |
73 * asynchronously. | |
74 */ | |
75 public void resume(); | |
76 | |
77 /** | |
78 * Note: There are deliberately no accessors for the results of the request | |
79 * here. Having none removes any ambiguity over when they are populated, | |
80 * particularly in the redirect case. | |
81 */ | |
82 } | |
83 | |
OLD | NEW |