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

Side by Side Diff: components/cronet/android/api/src/org/chromium/net/HttpUrlRequest.java

Issue 2339223002: Cronet API Refactoring (Closed)
Patch Set: Moved CronetSampleApp to AppCompat Created 4 years, 3 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
OLDNEW
(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 import java.io.IOException;
8 import java.nio.ByteBuffer;
9 import java.nio.channels.ReadableByteChannel;
10 import java.util.List;
11 import java.util.Map;
12
13 /**
14 * HTTP request (GET or POST).
15 * @deprecated Use {@link UrlRequest} instead.
16 * {@hide as it's deprecated}
17 */
18 @Deprecated
19 public interface HttpUrlRequest {
20
21 public static final int REQUEST_PRIORITY_IDLE = 0;
22
23 public static final int REQUEST_PRIORITY_LOWEST = 1;
24
25 public static final int REQUEST_PRIORITY_LOW = 2;
26
27 public static final int REQUEST_PRIORITY_MEDIUM = 3;
28
29 public static final int REQUEST_PRIORITY_HIGHEST = 4;
30
31 /**
32 * Returns the URL associated with this request.
33 */
34 String getUrl();
35
36 /**
37 * Requests a range starting at the given offset to the end of the resource.
38 * The server may or may not honor the offset request. The client must check
39 * the HTTP status code before processing the response.
40 */
41 void setOffset(long offset);
42
43 /**
44 * Limits the size of the download.
45 *
46 * @param limit Maximum size of the downloaded response (post gzip)
47 * @param cancelEarly If true, cancel the download as soon as the size of
48 * the response is known. If false, download {@code responseSize}
49 * bytes and then cancel.
50 */
51 void setContentLengthLimit(long limit, boolean cancelEarly);
52
53 /**
54 * Sets data to upload as part of a POST request.
55 *
56 * @param contentType MIME type of the post content or null if this is not a
57 * POST.
58 * @param data The content that needs to be uploaded if this is a POST
59 * request.
60 */
61 void setUploadData(String contentType, byte[] data);
62
63 /**
64 * Sets a readable byte channel to upload as part of a POST request.
65 *
66 * <p>Once {@link #start()} is called, this channel is guaranteed to be
67 * closed, either when the upload completes, or when it is canceled.
68 *
69 * @param contentType MIME type of the post content or null if this is not a
70 * POST.
71 * @param channel The channel to read to read upload data from if this is a
72 * POST request.
73 * @param contentLength The length of data to upload.
74 */
75 void setUploadChannel(String contentType, ReadableByteChannel channel,
76 long contentLength);
77
78 /**
79 * Sets the HTTP method verb to use for this request.
80 *
81 * <p>The default when this method is not called is "GET" if the request has
82 * no body or "POST" if it does.
83 *
84 * @param method "GET", "POST", etc. Must be all uppercase.
85 */
86 void setHttpMethod(String method);
87
88 /**
89 * Disables redirect for this request.
90 */
91 void disableRedirects();
92
93 /**
94 * Start executing the request.
95 * <p>
96 * If this is a streaming upload request using a ReadableByteChannel, the
97 * call will block while the request is uploaded.
98 */
99 void start();
100
101 /**
102 * Cancel the request in progress.
103 */
104 void cancel();
105
106 /**
107 * Returns {@code true} if the request has been canceled.
108 */
109 boolean isCanceled();
110
111 /**
112 * Returns protocol (e.g. "quic/1+spdy/3") negotiated with server. Returns
113 * empty string if no protocol was negotiated, or the protocol is not known.
114 * Returns empty when using plain http or https. Must be called after
115 * onResponseStarted but before request is recycled.
116 */
117 String getNegotiatedProtocol();
118
119 /**
120 * Returns whether the response is serviced from the cache.
121 */
122 boolean wasCached();
123
124 /**
125 * Returns the entire response as a ByteBuffer.
126 */
127 ByteBuffer getByteBuffer();
128
129 /**
130 * Returns the entire response as a byte array.
131 */
132 byte[] getResponseAsBytes();
133
134 /**
135 * Returns the expected content length. It is not guaranteed to be correct
136 * and may be -1 if the content length is unknown.
137 */
138 long getContentLength();
139
140 /**
141 * Returns the content MIME type if known or {@code null} otherwise.
142 */
143 String getContentType();
144
145 /**
146 * Returns the HTTP status code. It may be 0 if the request has not started
147 * or failed before getting the status code from the server. If the status
148 * code is 206 (partial response) after {@link #setOffset} is called, the
149 * method returns 200.
150 */
151 int getHttpStatusCode();
152
153 /**
154 * Returns the HTTP status text of the status line. For example, if the
155 * request has a "HTTP/1.1 200 OK" response, this method returns "OK". It
156 * returns null if the request has not started.
157 */
158 String getHttpStatusText();
159
160 /**
161 * Returns the response header value for the given name or {@code null} if
162 * not found.
163 */
164 String getHeader(String name);
165
166 /**
167 * Returns an unmodifiable map of the response-header fields and values.
168 * The null key is mapped to the HTTP status line for compatibility with
169 * HttpUrlConnection.
170 */
171 Map<String, List<String>> getAllHeaders();
172
173 /**
174 * Returns the exception that occurred while executing the request of null
175 * if the request was successful.
176 */
177 IOException getException();
178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698