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

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

Issue 230443005: Move cronet from //net into //components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
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
11 /**
12 * HTTP request (GET or POST).
13 */
14 public interface HttpUrlRequest {
15
16 public static final int REQUEST_PRIORITY_IDLE = 0;
17
18 public static final int REQUEST_PRIORITY_LOWEST = 1;
19
20 public static final int REQUEST_PRIORITY_LOW = 2;
21
22 public static final int REQUEST_PRIORITY_MEDIUM = 3;
23
24 public static final int REQUEST_PRIORITY_HIGHEST = 4;
25
26 /**
27 * Returns the URL associated with this request.
28 */
29 String getUrl();
30
31 /**
32 * Requests a range starting at the given offset to the end of the resource.
33 * The server may or may not honor the offset request. The client must check
34 * the HTTP status code before processing the response.
35 */
36 void setOffset(long offset);
37
38 /**
39 * Limits the size of the download.
40 *
41 * @param limit Maximum size of the downloaded response (post gzip)
42 * @param cancelEarly If true, cancel the download as soon as the size of
43 * the response is known. If false, download {@code responseSize}
44 * bytes and then cancel.
45 */
46 void setContentLengthLimit(long limit, boolean cancelEarly);
47
48 /**
49 * Sets data to upload as part of a POST request.
50 *
51 * @param contentType MIME type of the post content or null if this is not a
52 * POST.
53 * @param data The content that needs to be uploaded if this is a POST
54 * request.
55 */
56 void setUploadData(String contentType, byte[] data);
57
58 /**
59 * Sets a readable byte channel to upload as part of a POST request.
60 *
61 * @param contentType MIME type of the post content or null if this is not a
62 * POST.
63 * @param channel The channel to read to read upload data from if this is a
64 * POST request.
65 */
66 void setUploadChannel(String contentType, ReadableByteChannel channel);
67
68 /**
69 * Start executing the request.
70 * <p>
71 * If this is a streaming upload request using a ReadableByteChannel, the
72 * call will block while the request is uploaded.
73 */
74 void start();
75
76 /**
77 * Cancel the request in progress.
78 */
79 void cancel();
80
81 /**
82 * Returns {@code true} if the request has been canceled.
83 */
84 boolean isCanceled();
85
86 /**
87 * Returns the entire response as a ByteBuffer.
88 */
89 ByteBuffer getByteBuffer();
90
91 /**
92 * Returns the entire response as a byte array.
93 */
94 byte[] getResponseAsBytes();
95
96 /**
97 * Returns the expected content length. It is not guaranteed to be correct
98 * and may be -1 if the content length is unknown.
99 */
100 long getContentLength();
101
102 /**
103 * Returns the content MIME type if known or {@code null} otherwise.
104 */
105 String getContentType();
106
107 /**
108 * Returns the HTTP status code. It may be 0 if the request has not started
109 * or failed before getting the status code from the server. If the status
110 * code is 206 (partial response) after {@link #setOffset} is called, the
111 * method returns 200.
112 */
113 int getHttpStatusCode();
114
115 /**
116 * Returns the exception that occurred while executing the request of null
117 * if the request was successful.
118 */
119 IOException getException();
120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698