jruby-http-kit 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +1 -0
- data/example/config.ru +9 -0
- data/example/hello_world.rb +17 -0
- data/example/rack.rb +11 -0
- data/example/ring.rb +31 -0
- data/example/sinatra/app.rb +9 -0
- data/example/sinatra/config.ru +8 -0
- data/example/webmachine/Gemfile +4 -0
- data/example/webmachine/Gemfile.lock +16 -0
- data/example/webmachine/app.rb +37 -0
- data/jruby-http-kit.gemspec +25 -0
- data/lib/http_kit/rack_handler.rb +139 -0
- data/lib/http_kit/server.rb +62 -0
- data/lib/http_kit/version.rb +3 -0
- data/lib/http_kit.rb +6 -0
- data/lib/java/clojure-1.5.1.jar +0 -0
- data/lib/java/http-kit.jar +0 -0
- data/lib/rack/handler/http_kit.rb +3 -0
- data/lib/rack/http_kit.rb +3 -0
- data/lib/webmachine/adapters/ring.rb +135 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/test_resource.rb +75 -0
- data/spec/webmachine/ring_adapter_spec.rb +127 -0
- data/src/.classpath +7 -0
- data/src/.project +17 -0
- data/src/org/httpkit/BytesInputStream.class +0 -0
- data/src/org/httpkit/BytesInputStream.java +83 -0
- data/src/org/httpkit/DateFormatter.class +0 -0
- data/src/org/httpkit/DynamicBytes.class +0 -0
- data/src/org/httpkit/DynamicBytes.java +76 -0
- data/src/org/httpkit/HTTPException.class +0 -0
- data/src/org/httpkit/HTTPException.java +10 -0
- data/src/org/httpkit/HeaderMap.class +0 -0
- data/src/org/httpkit/HeaderMap.java +98 -0
- data/src/org/httpkit/HttpMethod.class +0 -0
- data/src/org/httpkit/HttpMethod.java +28 -0
- data/src/org/httpkit/HttpStatus.class +0 -0
- data/src/org/httpkit/HttpStatus.java +416 -0
- data/src/org/httpkit/HttpUtils.class +0 -0
- data/src/org/httpkit/HttpUtils.java +484 -0
- data/src/org/httpkit/HttpVersion.class +0 -0
- data/src/org/httpkit/HttpVersion.java +5 -0
- data/src/org/httpkit/LineReader.class +0 -0
- data/src/org/httpkit/LineReader.java +52 -0
- data/src/org/httpkit/LineTooLargeException.class +0 -0
- data/src/org/httpkit/LineTooLargeException.java +13 -0
- data/src/org/httpkit/PrefixThreadFactory.class +0 -0
- data/src/org/httpkit/PrefixThreadFactory.java +20 -0
- data/src/org/httpkit/PriorityQueue.class +0 -0
- data/src/org/httpkit/PriorityQueue.java +235 -0
- data/src/org/httpkit/ProtocolException.class +0 -0
- data/src/org/httpkit/ProtocolException.java +10 -0
- data/src/org/httpkit/RequestTooLargeException.class +0 -0
- data/src/org/httpkit/RequestTooLargeException.java +10 -0
- data/src/org/httpkit/client/AbortException.class +0 -0
- data/src/org/httpkit/client/AbortException.java +13 -0
- data/src/org/httpkit/client/Decoder.class +0 -0
- data/src/org/httpkit/client/Decoder.java +182 -0
- data/src/org/httpkit/client/Handler.class +0 -0
- data/src/org/httpkit/client/HttpClient.class +0 -0
- data/src/org/httpkit/client/HttpClient.java +393 -0
- data/src/org/httpkit/client/HttpsRequest.class +0 -0
- data/src/org/httpkit/client/HttpsRequest.java +141 -0
- data/src/org/httpkit/client/IFilter$1.class +0 -0
- data/src/org/httpkit/client/IFilter$MaxBodyFilter.class +0 -0
- data/src/org/httpkit/client/IFilter.class +0 -0
- data/src/org/httpkit/client/IFilter.java +53 -0
- data/src/org/httpkit/client/IRespListener.class +0 -0
- data/src/org/httpkit/client/IRespListener.java +30 -0
- data/src/org/httpkit/client/IResponseHandler.class +0 -0
- data/src/org/httpkit/client/IResponseHandler.java +18 -0
- data/src/org/httpkit/client/PersistentConn.class +0 -0
- data/src/org/httpkit/client/PersistentConn.java +33 -0
- data/src/org/httpkit/client/Request.class +0 -0
- data/src/org/httpkit/client/Request.java +74 -0
- data/src/org/httpkit/client/RequestConfig.class +0 -0
- data/src/org/httpkit/client/RequestConfig.java +28 -0
- data/src/org/httpkit/client/RespListener.class +0 -0
- data/src/org/httpkit/client/RespListener.java +160 -0
- data/src/org/httpkit/client/SslContextFactory.class +0 -0
- data/src/org/httpkit/client/SslContextFactory.java +79 -0
- data/src/org/httpkit/client/State.class +0 -0
- data/src/org/httpkit/client/TimeoutException.class +0 -0
- data/src/org/httpkit/client/TimeoutException.java +12 -0
- data/src/org/httpkit/client/TrustManagerFactory$1.class +0 -0
- data/src/org/httpkit/client/TrustManagerFactory.class +0 -0
- data/src/org/httpkit/server/AsyncChannel.class +0 -0
- data/src/org/httpkit/server/AsyncChannel.java +286 -0
- data/src/org/httpkit/server/ClojureRing.class +0 -0
- data/src/org/httpkit/server/Frame$BinaryFrame.class +0 -0
- data/src/org/httpkit/server/Frame$CloseFrame.class +0 -0
- data/src/org/httpkit/server/Frame$PingFrame.class +0 -0
- data/src/org/httpkit/server/Frame$TextFrame.class +0 -0
- data/src/org/httpkit/server/Frame.class +0 -0
- data/src/org/httpkit/server/Frame.java +73 -0
- data/src/org/httpkit/server/HttpAtta.class +0 -0
- data/src/org/httpkit/server/HttpAtta.java +10 -0
- data/src/org/httpkit/server/HttpDecoder$State.class +0 -0
- data/src/org/httpkit/server/HttpDecoder.class +0 -0
- data/src/org/httpkit/server/HttpDecoder.java +202 -0
- data/src/org/httpkit/server/HttpHandler.class +0 -0
- data/src/org/httpkit/server/HttpRequest.class +0 -0
- data/src/org/httpkit/server/HttpRequest.java +109 -0
- data/src/org/httpkit/server/HttpServer.class +0 -0
- data/src/org/httpkit/server/HttpServer.java +281 -0
- data/src/org/httpkit/server/IHandler.class +0 -0
- data/src/org/httpkit/server/IHandler.java +12 -0
- data/src/org/httpkit/server/LinkingRunnable.class +0 -0
- data/src/org/httpkit/server/Rack.class +0 -0
- data/src/org/httpkit/server/RackApplication.class +0 -0
- data/src/org/httpkit/server/RackApplication.java +10 -0
- data/src/org/httpkit/server/RackHandler$1.class +0 -0
- data/src/org/httpkit/server/RackHandler.class +0 -0
- data/src/org/httpkit/server/RackHandler.java +259 -0
- data/src/org/httpkit/server/RackHttpHandler.class +0 -0
- data/src/org/httpkit/server/RackHttpHandler.java +20 -0
- data/src/org/httpkit/server/RespCallback.class +0 -0
- data/src/org/httpkit/server/RespCallback.java +19 -0
- data/src/org/httpkit/server/RingHandler$1.class +0 -0
- data/src/org/httpkit/server/RingHandler.class +0 -0
- data/src/org/httpkit/server/RingHandler.java +222 -0
- data/src/org/httpkit/server/ServerAtta.class +0 -0
- data/src/org/httpkit/server/ServerAtta.java +22 -0
- data/src/org/httpkit/server/WSDecoder$State.class +0 -0
- data/src/org/httpkit/server/WSDecoder.class +0 -0
- data/src/org/httpkit/server/WSDecoder.java +181 -0
- data/src/org/httpkit/server/WSHandler.class +0 -0
- data/src/org/httpkit/server/WsAtta.class +0 -0
- data/src/org/httpkit/server/WsAtta.java +11 -0
- data/src/org/httpkit/timer/CancelableFutureTask.class +0 -0
- data/src/org/httpkit/timer/CancelableFutureTask.java +52 -0
- data/src/org/httpkit/timer/TimerService.class +0 -0
- data/src/org/httpkit/timer/TimerService.java +89 -0
- metadata +241 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
package org.httpkit;
|
|
2
|
+
|
|
3
|
+
import static org.httpkit.HttpUtils.ASCII;
|
|
4
|
+
|
|
5
|
+
public class HttpStatus {
|
|
6
|
+
|
|
7
|
+
private final int code;
|
|
8
|
+
private final String reasonPhrase;
|
|
9
|
+
private final byte[] bytes;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 100 Continue
|
|
13
|
+
*/
|
|
14
|
+
public static final HttpStatus CONTINUE = new HttpStatus(100, "Continue");
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 101 Switching Protocols
|
|
18
|
+
*/
|
|
19
|
+
public static final HttpStatus SWITCHING_PROTOCOLS = new HttpStatus(101, "Switching Protocols");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 102 Processing (WebDAV, RFC2518)
|
|
23
|
+
*/
|
|
24
|
+
public static final HttpStatus PROCESSING = new HttpStatus(102, "Processing");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 200 OK
|
|
28
|
+
*/
|
|
29
|
+
public static final HttpStatus OK = new HttpStatus(200, "OK");
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 201 Created
|
|
33
|
+
*/
|
|
34
|
+
public static final HttpStatus CREATED = new HttpStatus(201, "Created");
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 202 Accepted
|
|
38
|
+
*/
|
|
39
|
+
public static final HttpStatus ACCEPTED = new HttpStatus(202, "Accepted");
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 203 Non-Authoritative Information (since HTTP/1.1)
|
|
43
|
+
*/
|
|
44
|
+
public static final HttpStatus NON_AUTHORITATIVE_INFORMATION = new HttpStatus(203,
|
|
45
|
+
"Non-Authoritative Information");
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 204 No Content
|
|
49
|
+
*/
|
|
50
|
+
public static final HttpStatus NO_CONTENT = new HttpStatus(204, "No Content");
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 205 Reset Content
|
|
54
|
+
*/
|
|
55
|
+
public static final HttpStatus RESET_CONTENT = new HttpStatus(205, "Reset Content");
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 206 Partial Content
|
|
59
|
+
*/
|
|
60
|
+
public static final HttpStatus PARTIAL_CONTENT = new HttpStatus(206, "Partial Content");
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 207 Multi-Status (WebDAV, RFC2518)
|
|
64
|
+
*/
|
|
65
|
+
public static final HttpStatus MULTI_STATUS = new HttpStatus(207, "Multi-Status");
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 300 Multiple Choices
|
|
69
|
+
*/
|
|
70
|
+
public static final HttpStatus MULTIPLE_CHOICES = new HttpStatus(300, "Multiple Choices");
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 301 Moved Permanently
|
|
74
|
+
*/
|
|
75
|
+
public static final HttpStatus MOVED_PERMANENTLY = new HttpStatus(301, "Moved Permanently");
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 302 Found
|
|
79
|
+
*/
|
|
80
|
+
public static final HttpStatus FOUND = new HttpStatus(302, "Found");
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 303 See Other (since HTTP/1.1)
|
|
84
|
+
*/
|
|
85
|
+
public static final HttpStatus SEE_OTHER = new HttpStatus(303, "See Other");
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 304 Not Modified
|
|
89
|
+
*/
|
|
90
|
+
public static final HttpStatus NOT_MODIFIED = new HttpStatus(304, "Not Modified");
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 305 Use Proxy (since HTTP/1.1)
|
|
94
|
+
*/
|
|
95
|
+
public static final HttpStatus USE_PROXY = new HttpStatus(305, "Use Proxy");
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 307 Temporary Redirect (since HTTP/1.1)
|
|
99
|
+
*/
|
|
100
|
+
public static final HttpStatus TEMPORARY_REDIRECT = new HttpStatus(307, "Temporary Redirect");
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 400 Bad Request
|
|
104
|
+
*/
|
|
105
|
+
public static final HttpStatus BAD_REQUEST = new HttpStatus(400, "Bad Request");
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 401 Unauthorized
|
|
109
|
+
*/
|
|
110
|
+
public static final HttpStatus UNAUTHORIZED = new HttpStatus(401, "Unauthorized");
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 402 Payment Required
|
|
114
|
+
*/
|
|
115
|
+
public static final HttpStatus PAYMENT_REQUIRED = new HttpStatus(402, "Payment Required");
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 403 Forbidden
|
|
119
|
+
*/
|
|
120
|
+
public static final HttpStatus FORBIDDEN = new HttpStatus(403, "Forbidden");
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 404 Not Found
|
|
124
|
+
*/
|
|
125
|
+
public static final HttpStatus NOT_FOUND = new HttpStatus(404, "Not Found");
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 405 Method Not Allowed
|
|
129
|
+
*/
|
|
130
|
+
public static final HttpStatus METHOD_NOT_ALLOWED = new HttpStatus(405,
|
|
131
|
+
"Method Not Allowed");
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 406 Not Acceptable
|
|
135
|
+
*/
|
|
136
|
+
public static final HttpStatus NOT_ACCEPTABLE = new HttpStatus(406, "Not Acceptable");
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* 407 Proxy Authentication Required
|
|
140
|
+
*/
|
|
141
|
+
public static final HttpStatus PROXY_AUTHENTICATION_REQUIRED = new HttpStatus(407,
|
|
142
|
+
"Proxy Authentication Required");
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 408 Request Timeout
|
|
146
|
+
*/
|
|
147
|
+
public static final HttpStatus REQUEST_TIMEOUT = new HttpStatus(408, "Request Timeout");
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 409 Conflict
|
|
151
|
+
*/
|
|
152
|
+
public static final HttpStatus CONFLICT = new HttpStatus(409, "Conflict");
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 410 Gone
|
|
156
|
+
*/
|
|
157
|
+
public static final HttpStatus GONE = new HttpStatus(410, "Gone");
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 411 Length Required
|
|
161
|
+
*/
|
|
162
|
+
public static final HttpStatus LENGTH_REQUIRED = new HttpStatus(411, "Length Required");
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 412 Precondition Failed
|
|
166
|
+
*/
|
|
167
|
+
public static final HttpStatus PRECONDITION_FAILED = new HttpStatus(412,
|
|
168
|
+
"Precondition Failed");
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 413 Request Entity Too Large
|
|
172
|
+
*/
|
|
173
|
+
public static final HttpStatus REQUEST_ENTITY_TOO_LARGE = new HttpStatus(413,
|
|
174
|
+
"Request Entity Too Large");
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 414 Request-URI Too Long
|
|
178
|
+
*/
|
|
179
|
+
public static final HttpStatus REQUEST_URI_TOO_LONG = new HttpStatus(414,
|
|
180
|
+
"Request-URI Too Long");
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 415 Unsupported Media Type
|
|
184
|
+
*/
|
|
185
|
+
public static final HttpStatus UNSUPPORTED_MEDIA_TYPE = new HttpStatus(415,
|
|
186
|
+
"Unsupported Media Type");
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* 416 Requested Range Not Satisfiable
|
|
190
|
+
*/
|
|
191
|
+
public static final HttpStatus REQUESTED_RANGE_NOT_SATISFIABLE = new HttpStatus(416,
|
|
192
|
+
"Requested Range Not Satisfiable");
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 417 Expectation Failed
|
|
196
|
+
*/
|
|
197
|
+
public static final HttpStatus EXPECTATION_FAILED = new HttpStatus(417,
|
|
198
|
+
"Expectation Failed");
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* 422 Unprocessable Entity (WebDAV, RFC4918)
|
|
202
|
+
*/
|
|
203
|
+
public static final HttpStatus UNPROCESSABLE_ENTITY = new HttpStatus(422,
|
|
204
|
+
"Unprocessable Entity");
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 423 Locked (WebDAV, RFC4918)
|
|
208
|
+
*/
|
|
209
|
+
public static final HttpStatus LOCKED = new HttpStatus(423, "Locked");
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* 424 Failed Dependency (WebDAV, RFC4918)
|
|
213
|
+
*/
|
|
214
|
+
public static final HttpStatus FAILED_DEPENDENCY = new HttpStatus(424, "Failed Dependency");
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 425 Unordered Collection (WebDAV, RFC3648)
|
|
218
|
+
*/
|
|
219
|
+
public static final HttpStatus UNORDERED_COLLECTION = new HttpStatus(425, "Unordered Collection");
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 426 Upgrade Required (RFC2817)
|
|
223
|
+
*/
|
|
224
|
+
public static final HttpStatus UPGRADE_REQUIRED = new HttpStatus(426, "Upgrade Required");
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 500 Internal Server Error
|
|
228
|
+
*/
|
|
229
|
+
public static final HttpStatus INTERNAL_SERVER_ERROR = new HttpStatus(500, "Internal Server Error");
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 501 Not Implemented
|
|
233
|
+
*/
|
|
234
|
+
public static final HttpStatus NOT_IMPLEMENTED = new HttpStatus(501, "Not Implemented");
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 502 Bad Gateway
|
|
238
|
+
*/
|
|
239
|
+
public static final HttpStatus BAD_GATEWAY = new HttpStatus(502, "Bad Gateway");
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 503 Service Unavailable
|
|
243
|
+
*/
|
|
244
|
+
public static final HttpStatus SERVICE_UNAVAILABLE = new HttpStatus(503, "Service Unavailable");
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* 504 Gateway Timeout
|
|
248
|
+
*/
|
|
249
|
+
public static final HttpStatus GATEWAY_TIMEOUT = new HttpStatus(504, "Gateway Timeout");
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* 505 HTTP Version Not Supported
|
|
253
|
+
*/
|
|
254
|
+
public static final HttpStatus HTTP_VERSION_NOT_SUPPORTED = new HttpStatus(505,
|
|
255
|
+
"HTTP Version Not Supported");
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 506 Variant Also Negotiates (RFC2295)
|
|
259
|
+
*/
|
|
260
|
+
public static final HttpStatus VARIANT_ALSO_NEGOTIATES = new HttpStatus(506,
|
|
261
|
+
"Variant Also Negotiates");
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* 507 Insufficient Storage (WebDAV, RFC4918)
|
|
265
|
+
*/
|
|
266
|
+
public static final HttpStatus INSUFFICIENT_STORAGE = new HttpStatus(507,
|
|
267
|
+
"Insufficient Storage");
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 510 Not Extended (RFC2774)
|
|
271
|
+
*/
|
|
272
|
+
public static final HttpStatus NOT_EXTENDED = new HttpStatus(510, "Not Extended");
|
|
273
|
+
|
|
274
|
+
public static HttpStatus valueOf(int code) {
|
|
275
|
+
switch (code) {
|
|
276
|
+
case 100:
|
|
277
|
+
return CONTINUE;
|
|
278
|
+
case 101:
|
|
279
|
+
return SWITCHING_PROTOCOLS;
|
|
280
|
+
case 102:
|
|
281
|
+
return PROCESSING;
|
|
282
|
+
case 200:
|
|
283
|
+
return OK;
|
|
284
|
+
case 201:
|
|
285
|
+
return CREATED;
|
|
286
|
+
case 202:
|
|
287
|
+
return ACCEPTED;
|
|
288
|
+
case 203:
|
|
289
|
+
return NON_AUTHORITATIVE_INFORMATION;
|
|
290
|
+
case 204:
|
|
291
|
+
return NO_CONTENT;
|
|
292
|
+
case 205:
|
|
293
|
+
return RESET_CONTENT;
|
|
294
|
+
case 206:
|
|
295
|
+
return PARTIAL_CONTENT;
|
|
296
|
+
case 207:
|
|
297
|
+
return MULTI_STATUS;
|
|
298
|
+
case 300:
|
|
299
|
+
return MULTIPLE_CHOICES;
|
|
300
|
+
case 301:
|
|
301
|
+
return MOVED_PERMANENTLY;
|
|
302
|
+
case 302:
|
|
303
|
+
return FOUND;
|
|
304
|
+
case 303:
|
|
305
|
+
return SEE_OTHER;
|
|
306
|
+
case 304:
|
|
307
|
+
return NOT_MODIFIED;
|
|
308
|
+
case 305:
|
|
309
|
+
return USE_PROXY;
|
|
310
|
+
case 307:
|
|
311
|
+
return TEMPORARY_REDIRECT;
|
|
312
|
+
case 400:
|
|
313
|
+
return BAD_REQUEST;
|
|
314
|
+
case 401:
|
|
315
|
+
return UNAUTHORIZED;
|
|
316
|
+
case 402:
|
|
317
|
+
return PAYMENT_REQUIRED;
|
|
318
|
+
case 403:
|
|
319
|
+
return FORBIDDEN;
|
|
320
|
+
case 404:
|
|
321
|
+
return NOT_FOUND;
|
|
322
|
+
case 405:
|
|
323
|
+
return METHOD_NOT_ALLOWED;
|
|
324
|
+
case 406:
|
|
325
|
+
return NOT_ACCEPTABLE;
|
|
326
|
+
case 407:
|
|
327
|
+
return PROXY_AUTHENTICATION_REQUIRED;
|
|
328
|
+
case 408:
|
|
329
|
+
return REQUEST_TIMEOUT;
|
|
330
|
+
case 409:
|
|
331
|
+
return CONFLICT;
|
|
332
|
+
case 410:
|
|
333
|
+
return GONE;
|
|
334
|
+
case 411:
|
|
335
|
+
return LENGTH_REQUIRED;
|
|
336
|
+
case 412:
|
|
337
|
+
return PRECONDITION_FAILED;
|
|
338
|
+
case 413:
|
|
339
|
+
return REQUEST_ENTITY_TOO_LARGE;
|
|
340
|
+
case 414:
|
|
341
|
+
return REQUEST_URI_TOO_LONG;
|
|
342
|
+
case 415:
|
|
343
|
+
return UNSUPPORTED_MEDIA_TYPE;
|
|
344
|
+
case 416:
|
|
345
|
+
return REQUESTED_RANGE_NOT_SATISFIABLE;
|
|
346
|
+
case 417:
|
|
347
|
+
return EXPECTATION_FAILED;
|
|
348
|
+
case 422:
|
|
349
|
+
return UNPROCESSABLE_ENTITY;
|
|
350
|
+
case 423:
|
|
351
|
+
return LOCKED;
|
|
352
|
+
case 424:
|
|
353
|
+
return FAILED_DEPENDENCY;
|
|
354
|
+
case 425:
|
|
355
|
+
return UNORDERED_COLLECTION;
|
|
356
|
+
case 426:
|
|
357
|
+
return UPGRADE_REQUIRED;
|
|
358
|
+
case 500:
|
|
359
|
+
return INTERNAL_SERVER_ERROR;
|
|
360
|
+
case 501:
|
|
361
|
+
return NOT_IMPLEMENTED;
|
|
362
|
+
case 502:
|
|
363
|
+
return BAD_GATEWAY;
|
|
364
|
+
case 503:
|
|
365
|
+
return SERVICE_UNAVAILABLE;
|
|
366
|
+
case 504:
|
|
367
|
+
return GATEWAY_TIMEOUT;
|
|
368
|
+
case 505:
|
|
369
|
+
return HTTP_VERSION_NOT_SUPPORTED;
|
|
370
|
+
case 506:
|
|
371
|
+
return VARIANT_ALSO_NEGOTIATES;
|
|
372
|
+
case 507:
|
|
373
|
+
return INSUFFICIENT_STORAGE;
|
|
374
|
+
case 510:
|
|
375
|
+
return NOT_EXTENDED;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
final String reasonPhrase;
|
|
379
|
+
|
|
380
|
+
if (code < 100) {
|
|
381
|
+
reasonPhrase = "Unknown Status";
|
|
382
|
+
} else if (code < 200) {
|
|
383
|
+
reasonPhrase = "Informational";
|
|
384
|
+
} else if (code < 300) {
|
|
385
|
+
reasonPhrase = "Successful";
|
|
386
|
+
} else if (code < 400) {
|
|
387
|
+
reasonPhrase = "Redirection";
|
|
388
|
+
} else if (code < 500) {
|
|
389
|
+
reasonPhrase = "Client Error";
|
|
390
|
+
} else if (code < 600) {
|
|
391
|
+
reasonPhrase = "Server Error";
|
|
392
|
+
} else {
|
|
393
|
+
reasonPhrase = "Unknown Status";
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return new HttpStatus(code, reasonPhrase + " (" + code + ')');
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
public HttpStatus(int code, String reasonPhrase) {
|
|
400
|
+
this.code = code;
|
|
401
|
+
this.reasonPhrase = reasonPhrase;
|
|
402
|
+
bytes = ("HTTP/1.1 " + code + " " + reasonPhrase + "\r\n").getBytes(ASCII);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
public int getCode() {
|
|
406
|
+
return code;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
public String getReasonPhrase() {
|
|
410
|
+
return reasonPhrase;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
public byte[] getInitialLineBytes() {
|
|
414
|
+
return bytes;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
Binary file
|