-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathRequest.java
197 lines (165 loc) · 4.67 KB
/
Request.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/*
* Copyright 2010 Ning, Inc.
*
* This program is licensed to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
*/
package org.asynchttpclient;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.cookie.Cookie;
import io.netty.resolver.NameResolver;
import org.asynchttpclient.channel.ChannelPoolPartitioning;
import org.asynchttpclient.cookie.CookieStore;
import org.asynchttpclient.proxy.ProxyServer;
import org.asynchttpclient.request.body.generator.BodyGenerator;
import org.asynchttpclient.request.body.multipart.Part;
import org.asynchttpclient.uri.Uri;
import java.io.File;
import java.io.InputStream;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.List;
/**
* The Request class can be used to construct HTTP request:
* <blockquote><pre>
* Request r = new RequestBuilder()
* .setUrl("url")
* .setRealm(
* new Realm.Builder("principal", "password")
* .setRealmName("MyRealm")
* .setScheme(Realm.AuthScheme.BASIC)
* ).build();
* </pre></blockquote>
*/
public interface Request {
/**
* @return the request's HTTP method (GET, POST, etc.)
*/
String getMethod();
/**
* @return the uri
*/
Uri getUri();
/**
* @return the url (the uri's String form)
*/
String getUrl();
/**
* @return the InetAddress to be used to bypass uri's hostname resolution
*/
InetAddress getAddress();
/**
* @return the local address to bind from
*/
InetAddress getLocalAddress();
/**
* @return the HTTP headers
*/
HttpHeaders getHeaders();
/**
* @return the HTTP cookies
*/
List<Cookie> getCookies();
/**
* @return the cookie store
*/
CookieStore getCookieStore();
/**
* @return the request's body byte array (only non null if it was set this way)
*/
byte[] getByteData();
/**
* @return the request's body array of byte arrays (only non null if it was set this way)
*/
List<byte[]> getCompositeByteData();
/**
* @return the request's body string (only non null if it was set this way)
*/
String getStringData();
/**
* @return the request's body ByteBuffer (only non null if it was set this way)
*/
ByteBuffer getByteBufferData();
/**
* @return the request's body InputStream (only non null if it was set this way)
*/
InputStream getStreamData();
/**
* @return the request's body BodyGenerator (only non null if it was set this way)
*/
BodyGenerator getBodyGenerator();
/**
* @return the request's form parameters
*/
List<Param> getFormParams();
/**
* @return the multipart parts
*/
List<Part> getBodyParts();
/**
* @return the virtual host to connect to
*/
String getVirtualHost();
/**
* @return the query params resolved from the url/uri
*/
List<Param> getQueryParams();
/**
* @return the proxy server to be used to perform this request (overrides the one defined in config)
*/
ProxyServer getProxyServer();
/**
* @return the realm to be used to perform this request (overrides the one defined in config)
*/
Realm getRealm();
/**
* @return the file to be uploaded
*/
File getFile();
/**
* @return if this request is to follow redirects. Non null values means "override config value".
*/
Boolean getFollowRedirect();
/**
* @return the request timeout. Non zero values means "override config value".
*/
int getRequestTimeout();
/**
* @return the read timeout. Non zero values means "override config value".
*/
int getReadTimeout();
/**
* @return the range header value, or 0 is not set.
*/
long getRangeOffset();
/**
* @return the charset value used when decoding the request's body.
*/
Charset getCharset();
/**
* @return the strategy to compute ChannelPool's keys
*/
ChannelPoolPartitioning getChannelPoolPartitioning();
/**
* @return the NameResolver to be used to resolve hostnams's IP
*/
NameResolver<InetAddress> getNameResolver();
/**
* @return a new request builder using this request as a prototype
*/
@SuppressWarnings("deprecation")
default RequestBuilder toBuilder() {
return new RequestBuilder(this);
}
}