1 | #Region "Microsoft.VisualBasic::81ea4e8bc9ad9472fa415e88abef22a2, Microsoft.VisualBasic.Core\Extensions\WebServices\NetResponse.vb" |
2 | |
3 | ' Author: |
4 | ' |
5 | ' asuka (amethyst.asuka@gcmodeller.org) |
6 | ' xie (genetics@smrucc.org) |
7 | ' xieguigang (xie.guigang@live.com) |
8 | ' |
9 | ' Copyright (c) 2018 GPL3 Licensed |
10 | ' |
11 | ' |
12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
13 | ' |
14 | ' |
15 | ' This program is free software: you can redistribute it and/or modify |
16 | ' it under the terms of the GNU General Public License as published by |
17 | ' the Free Software Foundation, either version 3 of the License, or |
18 | ' (at your option) any later version. |
19 | ' |
20 | ' This program is distributed in the hope that it will be useful, |
21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | ' GNU General Public License for more details. |
24 | ' |
25 | ' You should have received a copy of the GNU General Public License |
26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | |
28 | |
29 | |
30 | ' /********************************************************************************/ |
31 | |
32 | ' Summaries: |
33 | |
34 | ' Module NetResponse |
35 | ' |
36 | ' Properties: RFC_ACCEPTED, RFC_ALREADY_REPORTED, RFC_AUTH_TIMEOUT, RFC_BAD_GATEWAY, RFC_BAD_REQUEST |
37 | ' RFC_BANDWIDTH_LIMITED_EXCEEDED, RFC_BLOCKED, RFC_CERT_ERROR, RFC_CLOSED_REQUEST, RFC_CONFLICT |
38 | ' RFC_CONNECT_TIMEOUT_ERROR, RFC_CONNECTION_TIMEOUT, RFC_CONTINUTE, RFC_CREATED, RFC_ENHANCE_YOUR_CALM |
39 | ' RFC_EXPECTATION_FAILED, RFC_FAILED_DEPENDENCY, RFC_FORBIDDEN, RFC_FOUND, RFC_GATEWAY_TIMEOUT |
40 | ' RFC_GONE, RFC_HTTP_TO_HTTPS, RFC_IM_TEAPOT, RFC_IM_USED, RFC_INSUFFICIENT_STORAGE |
41 | ' RFC_INTERNAL_SERVER_ERROR, RFC_LEGAL_UNAVAILABLE, RFC_LENGTH_REQUIRED, RFC_LOCKED, RFC_LOGIN_TIMEOUT |
42 | ' RFC_LOOP_DETECTED, RFC_METHOD_FAILURE, RFC_METHOD_NOT_ALLOWED, RFC_MISDIRECTED_REQUEST, RFC_MOVED_PERMANENTLY |
43 | ' RFC_MULTI_CHOICES, RFC_MULTI_STATUS, RFC_NEGOTIATES, RFC_NETWORK_AUTH_REQUIRED, RFC_NO_CERT |
44 | ' RFC_NO_CONTENT, RFC_NO_RESPONSE, RFC_NON_AUTH_INFO, RFC_NOT_ACCEPTABLE, RFC_NOT_EXTENDED |
45 | ' RFC_NOT_FOUND, RFC_NOT_IMPLEMENTED, RFC_NOT_MODIFIED, RFC_OK, RFC_PARTIAL_CONTENT |
46 | ' RFC_PAYLOAD_TOO_LARGE, RFC_PAYMENT_REQUIRED, RFC_PERMANENT_REDIRECT, RFC_PRECONDITION_FAILED, RFC_PRECONDITION_REQUIRED |
47 | ' RFC_PROCESSING, RFC_PROXY_AUTH_REQUIRED, RFC_RANGE_NOT_SATISFIABLE, RFC_READ_TIMEOUT_ERROR, RFC_REDIRECT |
48 | ' RFC_REQUEST_HEADER_FIELDS_TOO_LARGE, RFC_REQUEST_HEADER_TOO_LARGE, RFC_REQUEST_TIMEOUT, RFC_RESET_CONTENT, RFC_RESUME_INCOMPLETE |
49 | ' RFC_RETRY_WITH, RFC_SEE_OTHER, RFC_SERVICE_UNAVAILABLE, RFC_SWITCH_PROXY, RFC_SWITCHING_PROTOCOLS |
50 | ' RFC_TEMP_REDIRECT, RFC_TOKEN_INVALID, RFC_TOKEN_REQUIRED, RFC_TOO_MANY_REQUEST, RFC_UNAUTHORIZED |
51 | ' RFC_UNKNOWN_ERROR, RFC_UNPROCESSABLE_ENTITY, RFC_UNSUPPORTED_MEDIA_TYPE, RFC_UPGRADE_REQUIRED, RFC_URI_TOO_LONG |
52 | ' RFC_USE_PROXY, RFC_VERSION_NOT_SUPPORTED |
53 | ' |
54 | ' Function: IsHTTP_RFC |
55 | ' |
56 | ' |
57 | ' /********************************************************************************/ |
58 | |
59 | #End Region |
60 | |
61 | Imports System.Runtime.CompilerServices |
62 | Imports System.Text.RegularExpressions |
63 | Imports Microsoft.VisualBasic.Net.Protocols |
64 | |
65 | Namespace Net.Http |
66 | |
67 | ''' <summary> |
68 | ''' The following is a list of Hypertext Transfer Protocol (HTTP) response status codes. This includes codes from IETF internet standards |
69 | ''' as well as other IETF RFCs, other specifications and some additional commonly used codes. The first digit of the status code specifies |
70 | ''' one of five classes of response; the bare minimum for an HTTP client is that it recognises these five classes. The phrases used are the |
71 | ''' standard examples, but any human-readable alternative can be provided. Unless otherwise stated, the status code is part of the HTTP/1.1 |
72 | ''' standard (RFC 7231). |
73 | ''' |
74 | ''' The Internet Assigned Numbers Authority (IANA) maintains the official registry Of HTTP status codes. |
75 | ''' |
76 | ''' Microsoft IIS sometimes uses additional Decimal Sub-codes To provide more specific information, but these are Not listed here. |
77 | ''' </summary> |
78 | Public Module NetResponse |
79 | |
80 | #Region "1xx Informational" |
81 | |
82 | ''' <summary> |
83 | ''' 100 Continue | |
84 | ''' This means that the server has received the request headers, And that the client should proceed To send the request body |
85 | ''' (In the Case Of a request For which a body needs To be sent; For example, a POST request). If the request body Is large, |
86 | ''' sending it To a server When a request has already been rejected based upon inappropriate headers Is inefficient. |
87 | ''' To have a server check If the request could be accepted based On the request's headers alone, a client must send Expect: |
88 | ''' 100-continue as a header in its initial request and check if a 100 Continue status code is received in response before |
89 | ''' continuing (or receive 417 Expectation Failed and not continue). |
90 | ''' </summary> |
91 | ''' <returns></returns> |
92 | Public ReadOnly Property RFC_CONTINUTE As RequestStream |
93 | ''' <summary> |
94 | ''' 101 Switching Protocols | |
95 | ''' This means the requester has asked the server To switch protocols And the server Is acknowledging that it will Do so. |
96 | ''' </summary> |
97 | ''' <returns></returns> |
98 | Public ReadOnly Property RFC_SWITCHING_PROTOCOLS As RequestStream |
99 | ''' <summary> |
100 | ''' 102 Processing (WebDAV; RFC 2518) | |
101 | ''' As a WebDAV request may contain many sub-requests involving file operations, it may take a long time to complete the request. |
102 | ''' This code indicates that the server has received And Is processing the request, but no response Is available yet.[3] |
103 | ''' This prevents the client from timing out And assuming the request was lost. |
104 | ''' </summary> |
105 | ''' <returns></returns> |
106 | Public ReadOnly Property RFC_PROCESSING As RequestStream |
107 | #End Region |
108 | |
109 | #Region "2xx Success" |
110 | |
111 | ''' <summary> |
112 | ''' 200 OK | |
113 | ''' Standard response For successful HTTP requests. The actual response will depend On the request method used. In a Get request, |
114 | ''' the response will contain an entity corresponding To the requested resource. In a POST request, the response will contain an |
115 | ''' entity describing Or containing the result Of the action. |
116 | ''' (由于可能会修改附带一些其他的元素据信息,所以只读属性不会使用简写的形式的,而是需要重新生成新的对象实例以防止数据污染) |
117 | ''' </summary> |
118 | ''' <returns></returns> |
119 | Public ReadOnly Property RFC_OK As RequestStream |
120 | Get |
121 | Return New RequestStream(0, HTTP_RFC.RFC_OK, "HTTP/200") |
122 | End Get |
123 | End Property |
124 | |
125 | ''' <summary> |
126 | ''' 201 Created | |
127 | ''' The request has been fulfilled And resulted In a New resource being created. |
128 | ''' </summary> |
129 | ''' <returns></returns> |
130 | Public ReadOnly Property RFC_CREATED As RequestStream |
131 | |
132 | ''' <summary> |
133 | ''' 202 Accepted | |
134 | ''' The request has been accepted For processing, but the processing has Not been completed. The request might Or might Not eventually be acted upon, |
135 | ''' As it might be disallowed When processing actually takes place. |
136 | ''' </summary> |
137 | ''' <returns></returns> |
138 | Public ReadOnly Property RFC_ACCEPTED As RequestStream |
139 | |
140 | ''' <summary> |
141 | ''' 203 Non-Authoritative Information (since HTTP/1.1) | |
142 | ''' The server successfully processed the request, but Is returning information that may be from another source. |
143 | ''' </summary> |
144 | ''' <returns></returns> |
145 | Public ReadOnly Property RFC_NON_AUTH_INFO As RequestStream |
146 | |
147 | ''' <summary> |
148 | ''' 204 No Content | |
149 | ''' The server successfully processed the request, but Is Not returning any content. |
150 | ''' </summary> |
151 | ''' <returns></returns> |
152 | Public ReadOnly Property RFC_NO_CONTENT As RequestStream |
153 | Get |
154 | Return New RequestStream(0, 204, "HTTP/204") |
155 | End Get |
156 | End Property |
157 | |
158 | ''' <summary> |
159 | ''' 205 Reset Content | |
160 | ''' The server successfully processed the request, but Is Not returning any content. Unlike a 204 response, this response requires that the requester reset the document view. |
161 | ''' </summary> |
162 | ''' <returns></returns> |
163 | Public ReadOnly Property RFC_RESET_CONTENT As RequestStream |
164 | |
165 | ''' <summary> |
166 | ''' 206 Partial Content (RFC 7233) | |
167 | ''' The server Is delivering only part Of the resource (Byte serving) due To a range header sent by the client. |
168 | ''' The range header Is used by HTTP clients To enable resuming Of interrupted downloads, Or split a download into multiple simultaneous streams. |
169 | ''' </summary> |
170 | ''' <returns></returns> |
171 | Public ReadOnly Property RFC_PARTIAL_CONTENT As RequestStream |
172 | |
173 | ''' <summary> |
174 | ''' 207 Multi-Status (WebDAV; RFC 4918) | |
175 | ''' The message body that follows Is an XML message And can contain a number Of separate response codes, depending On how many Sub-requests were made.[4] |
176 | ''' </summary> |
177 | ''' <returns></returns> |
178 | Public ReadOnly Property RFC_MULTI_STATUS As RequestStream |
179 | ''' <summary> |
180 | ''' 208 Already Reported (WebDAV; RFC 5842) | |
181 | ''' The members Of a DAV binding have already been enumerated In a previous reply To this request, And are Not being included again. |
182 | ''' </summary> |
183 | ''' <returns></returns> |
184 | Public ReadOnly Property RFC_ALREADY_REPORTED As RequestStream |
185 | ''' <summary> |
186 | ''' 226 IM Used (RFC 3229) | |
187 | ''' The server has fulfilled a request For the resource, And the response Is a representation Of the result Of one Or more instance-manipulations applied To the current instance.[5] |
188 | ''' </summary> |
189 | ''' <returns></returns> |
190 | Public ReadOnly Property RFC_IM_USED As RequestStream |
191 | #End Region |
192 | |
193 | #Region "3xx Redirection" |
194 | |
195 | ''' <summary> |
196 | ''' 300 Multiple Choices | |
197 | ''' Indicates multiple options For the resource that the client may follow. It, For instance, could be used To present different |
198 | ''' format options For video, list files With different extensions, Or word sense disambiguation. |
199 | ''' </summary> |
200 | ''' <returns></returns> |
201 | Public ReadOnly Property RFC_MULTI_CHOICES As RequestStream |
202 | ''' <summary> |
203 | ''' 301 Moved Permanently | |
204 | ''' This And all future requests should be directed to the given URI. |
205 | ''' </summary> |
206 | ''' <returns></returns> |
207 | Public ReadOnly Property RFC_MOVED_PERMANENTLY As RequestStream |
208 | ''' <summary> |
209 | ''' 302 Found | |
210 | ''' This Is an example of industry practice contradicting the standard. The HTTP/1.0 specification (RFC 1945) required the client |
211 | ''' to perform a temporary redirect (the original describing phrase was "Moved Temporarily"),[6] but popular browsers implemented |
212 | ''' 302 with the functionality of a 303 See Other. Therefore, HTTP/1.1 added status codes 303 And 307 to distinguish between the |
213 | ''' two behaviours.[7] However, some Web applications And frameworks use the 302 status code as if it were the 303.[8] |
214 | ''' </summary> |
215 | ''' <returns></returns> |
216 | Public ReadOnly Property RFC_FOUND As RequestStream |
217 | ''' <summary> |
218 | ''' 303 See Other (since HTTP/1.1) | |
219 | ''' The response To the request can be found under another URI Using a Get method. When received In response To a POST (Or PUT/DELETE), |
220 | ''' it should be assumed that the server has received the data And the redirect should be issued With a separate Get message. |
221 | ''' </summary> |
222 | ''' <returns></returns> |
223 | Public ReadOnly Property RFC_SEE_OTHER As RequestStream |
224 | ''' <summary> |
225 | ''' 304 Not Modified (RFC 7232) | |
226 | ''' Indicates that the resource has Not been modified since the version specified by the request headers If-Modified-Since Or If-None-Match. |
227 | ''' This means that there Is no need To retransmit the resource, since the client still has a previously-downloaded copy. |
228 | ''' </summary> |
229 | ''' <returns></returns> |
230 | Public ReadOnly Property RFC_NOT_MODIFIED As RequestStream |
231 | ''' <summary> |
232 | ''' 305 Use Proxy (since HTTP/1.1) | |
233 | ''' The requested resource Is only available through a proxy, whose address Is provided In the response. Many HTTP clients |
234 | ''' (such As Mozilla[9] And Internet Explorer) Do Not correctly handle responses With this status code, primarily For security reasons.[10] |
235 | ''' </summary> |
236 | ''' <returns></returns> |
237 | Public ReadOnly Property RFC_USE_PROXY As RequestStream |
238 | ''' <summary> |
239 | ''' 306 Switch Proxy | |
240 | ''' No longer used. Originally meant "Subsequent requests should use the specified proxy."[11] |
241 | ''' </summary> |
242 | ''' <returns></returns> |
243 | Public ReadOnly Property RFC_SWITCH_PROXY As RequestStream |
244 | ''' <summary> |
245 | ''' 307 Temporary Redirect (since HTTP/1.1) | |
246 | ''' In this case, the request should be repeated with another URI; however, future requests should still use the original URI. |
247 | ''' In contrast to how 302 was historically implemented, the request method Is Not allowed to be changed when reissuing the original request. |
248 | ''' For instance, a POST request should be repeated using another POST request.[12] |
249 | ''' </summary> |
250 | ''' <returns></returns> |
251 | Public ReadOnly Property RFC_TEMP_REDIRECT As RequestStream |
252 | Get |
253 | Return New RequestStream(0, HTTP_RFC.RFC_TEMP_REDIRECT, "HTTP/307") |
254 | End Get |
255 | End Property |
256 | |
257 | ''' <summary> |
258 | ''' 308 Permanent Redirect (RFC 7538) | |
259 | ''' The request, and all future requests should be repeated Using another URI. 307 And 308 (As proposed) parallel the behaviours |
260 | ''' Of 302 And 301, but Do Not allow the HTTP method To change. So, For example, submitting a form To a permanently redirected resource may Continue smoothly.[13] |
261 | ''' </summary> |
262 | ''' <returns></returns> |
263 | Public ReadOnly Property RFC_PERMANENT_REDIRECT As RequestStream |
264 | ''' <summary> |
265 | ''' 308 Resume Incomplete (Google) | |
266 | ''' This code Is used In the Resumable HTTP Requests Proposal To Resume aborted PUT Or POST requests.[14] |
267 | ''' </summary> |
268 | ''' <returns></returns> |
269 | Public ReadOnly Property RFC_RESUME_INCOMPLETE As RequestStream |
270 | #End Region |
271 | |
272 | #Region "4xx Client Error" |
273 | |
274 | ''' <summary> |
275 | ''' 400 Bad Request | |
276 | ''' The server cannot Or will Not process the request due To something that Is perceived To be a client Error (e.g., malformed request syntax, |
277 | ''' invalid request message framing, Or deceptive request routing).[15] |
278 | ''' </summary> |
279 | ''' <returns></returns> |
280 | Public ReadOnly Property RFC_BAD_REQUEST As RequestStream |
281 | Get |
282 | Return New RequestStream(0, HTTP_RFC.RFC_BAD_REQUEST, "HTTP/400") |
283 | End Get |
284 | End Property |
285 | |
286 | ''' <summary> |
287 | ''' 401 Unauthorized (RFC 7235) | |
288 | ''' Similar to 403 Forbidden, but specifically for use when authentication Is required And has failed Or has Not yet been provided. |
289 | ''' The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. |
290 | ''' See Basic access authentication And Digest access authentication.(证书未认证) |
291 | ''' </summary> |
292 | ''' <returns></returns> |
293 | Public ReadOnly Property RFC_UNAUTHORIZED As RequestStream |
294 | Get |
295 | Return New RequestStream(0, HTTP_RFC.RFC_UNAUTHORIZED, "HTTP/401") |
296 | End Get |
297 | End Property |
298 | |
299 | ''' <summary> |
300 | ''' 402 Payment Required | |
301 | ''' Reserved for future use. The original intention was that this code might be used as part of some form of digital cash Or micropayment scheme, |
302 | ''' but that has Not happened, And this code Is Not usually used. YouTube uses this status if a particular IP address has made excessive requests, |
303 | ''' And requires the person to enter a CAPTCHA.[citation needed] |
304 | ''' </summary> |
305 | ''' <returns></returns> |
306 | Public ReadOnly Property RFC_PAYMENT_REQUIRED As RequestStream |
307 | ''' <summary> |
308 | ''' 403 Forbidden | |
309 | ''' The request was a valid request, but the server Is refusing To respond To it. Unlike a 401 Unauthorized response, authenticating will make no difference. |
310 | ''' (被封号了) |
311 | ''' </summary> |
312 | ''' <returns></returns> |
313 | Public ReadOnly Property RFC_FORBIDDEN As RequestStream |
314 | Get |
315 | Return New RequestStream(0, HTTP_RFC.RFC_FORBIDDEN, "HTTP/403") |
316 | End Get |
317 | End Property |
318 | |
319 | ''' <summary> |
320 | ''' 404 Not Found | |
321 | ''' The requested resource could Not be found but may be available again In the future. Subsequent requests by the client are permissible. |
322 | ''' </summary> |
323 | ''' <returns></returns> |
324 | Public ReadOnly Property RFC_NOT_FOUND As RequestStream |
325 | Get |
326 | Return New RequestStream(0, HTTP_RFC.RFC_NOT_FOUND, "HTTP/404") |
327 | End Get |
328 | End Property |
329 | |
330 | ''' <summary> |
331 | ''' 405 Method Not Allowed | |
332 | ''' A request was made Of a resource Using a request method Not supported by that resource; For example, |
333 | ''' Using Get On a form which requires data To be presented via POST, Or Using PUT On a read-only resource. |
334 | ''' </summary> |
335 | ''' <returns></returns> |
336 | Public ReadOnly Property RFC_METHOD_NOT_ALLOWED As RequestStream |
337 | ''' <summary> |
338 | ''' 406 Not Acceptable | |
339 | ''' The requested resource Is only capable Of generating content Not acceptable according To the Accept headers sent In the request. |
340 | ''' </summary> |
341 | ''' <returns></returns> |
342 | Public ReadOnly Property RFC_NOT_ACCEPTABLE As RequestStream |
343 | ''' <summary> |
344 | ''' 407 Proxy Authentication Required (RFC 7235) | |
345 | ''' The client must first authenticate itself With the proxy. |
346 | ''' </summary> |
347 | ''' <returns></returns> |
348 | Public ReadOnly Property RFC_PROXY_AUTH_REQUIRED As RequestStream |
349 | ''' <summary> |
350 | ''' 408 Request Timeout | |
351 | ''' The server timed out waiting For the request. According To HTTP specifications: |
352 | ''' "The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time." |
353 | ''' (请求超时) |
354 | ''' </summary> |
355 | ''' <returns></returns> |
356 | Public ReadOnly Property RFC_REQUEST_TIMEOUT As RequestStream = New RequestStream(0, HTTP_RFC.RFC_REQUEST_TIMEOUT, "HTTP/408") |
357 | |
358 | ''' <summary> |
359 | ''' 409 Conflict | |
360 | ''' Indicates that the request could Not be processed because Of conflict In the request, such As an edit conflict In the Case Of multiple updates. |
361 | ''' </summary> |
362 | ''' <returns></returns> |
363 | Public ReadOnly Property RFC_CONFLICT As RequestStream = New RequestStream(0, HTTP_RFC.RFC_CONFLICT, "HTTP/409") |
364 | ''' <summary> |
365 | ''' 410 Gone | |
366 | ''' Indicates that the resource requested Is no longer available And will Not be available again. |
367 | ''' This should be used When a resource has been intentionally removed And the resource should be purged. |
368 | ''' Upon receiving a 410 status code, the client should Not request the resource again In the future. |
369 | ''' Clients such As search engines should remove the resource from their indices.[16] Most use cases |
370 | ''' Do Not require clients And search engines To purge the resource, And a "404 Not Found" may be used instead. |
371 | ''' </summary> |
372 | ''' <returns></returns> |
373 | Public ReadOnly Property RFC_GONE As RequestStream |
374 | |
375 | ''' <summary> |
376 | ''' 411 Length Required | |
377 | ''' The request did Not specify the length Of its content, which Is required by the requested resource. |
378 | ''' </summary> |
379 | ''' <returns></returns> |
380 | Public ReadOnly Property RFC_LENGTH_REQUIRED As RequestStream |
381 | ''' <summary> |
382 | ''' 412 Precondition Failed (RFC 7232) | |
383 | ''' The server does Not meet one Of the preconditions that the requester put On the request. |
384 | ''' </summary> |
385 | ''' <returns></returns> |
386 | Public ReadOnly Property RFC_PRECONDITION_FAILED As RequestStream |
387 | |
388 | ''' <summary> |
389 | ''' 413 Payload Too Large (RFC 7231) | |
390 | ''' The request Is larger than the server Is willing Or able To process. Called "Request Entity Too Large " previously. |
391 | ''' </summary> |
392 | ''' <returns></returns> |
393 | Public ReadOnly Property RFC_PAYLOAD_TOO_LARGE As RequestStream |
394 | ''' <summary> |
395 | ''' 414 Request-URI Too Long | |
396 | ''' The URI provided was too Long For the server To process. Often the result Of too much data being encoded As a query-String Of a Get request, In which Case it should be converted To a POST request. |
397 | ''' </summary> |
398 | ''' <returns></returns> |
399 | Public ReadOnly Property RFC_URI_TOO_LONG As RequestStream |
400 | ''' <summary> |
401 | ''' 415 Unsupported Media Type | |
402 | ''' The request entity has a media type which the server Or resource does Not support. For example, the client uploads an image As image/svg+xml, but the server requires that images use a different format. |
403 | ''' </summary> |
404 | ''' <returns></returns> |
405 | Public ReadOnly Property RFC_UNSUPPORTED_MEDIA_TYPE As RequestStream |
406 | ''' <summary> |
407 | ''' 416 Requested Range Not Satisfiable (RFC 7233) | |
408 | ''' The client has asked For a portion Of the file (Byte serving), but the server cannot supply that portion. For example, If the client asked For a part Of the file that lies beyond the End Of the file. |
409 | ''' </summary> |
410 | ''' <returns></returns> |
411 | Public ReadOnly Property RFC_RANGE_NOT_SATISFIABLE As RequestStream |
412 | ''' <summary> |
413 | ''' 417 Expectation Failed | |
414 | ''' The server cannot meet the requirements Of the Expect request-header field. |
415 | ''' </summary> |
416 | ''' <returns></returns> |
417 | Public ReadOnly Property RFC_EXPECTATION_FAILED As RequestStream |
418 | Get |
419 | Return New RequestStream(0, 417, "HTTP/417") |
420 | End Get |
421 | End Property |
422 | ''' <summary> |
423 | ''' 418 I'm a teapot (RFC 2324) | |
424 | ''' This code was defined In 1998 As one Of the traditional IETF April Fools' jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, |
425 | ''' and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by tea pots requested to brew coffee. |
426 | ''' </summary> |
427 | ''' <returns></returns> |
428 | Public ReadOnly Property RFC_IM_TEAPOT As RequestStream |
429 | ''' <summary> |
430 | ''' 419 Authentication Timeout (Not in RFC 2616) | |
431 | ''' Not a part of the HTTP standard, 419 Authentication Timeout denotes that previously valid authentication has expired. |
432 | ''' It Is used as an alternative to 401 Unauthorized in order to differentiate from otherwise authenticated clients being denied access to specific server resources.[citation needed] |
433 | ''' </summary> |
434 | ''' <returns></returns> |
435 | Public ReadOnly Property RFC_AUTH_TIMEOUT As RequestStream |
436 | ''' <summary> |
437 | ''' 420 Method Failure (Spring Framework) | |
438 | ''' Not part of the HTTP standard, but defined by Spring in the HttpStatus class to be used when a method failed. This status code Is deprecated by Spring. |
439 | ''' </summary> |
440 | ''' <returns></returns> |
441 | Public ReadOnly Property RFC_METHOD_FAILURE As RequestStream |
442 | ''' <summary> |
443 | ''' 420 Enhance Your Calm (Twitter) | |
444 | ''' Not part of the HTTP standard, but returned by version 1 of the Twitter Search And Trends API when the client Is being rate limited.[17] |
445 | ''' Other services may wish to implement the 429 Too Many Requests response code instead. |
446 | ''' </summary> |
447 | ''' <returns></returns> |
448 | Public ReadOnly Property RFC_ENHANCE_YOUR_CALM As RequestStream |
449 | ''' <summary> |
450 | ''' 421 Misdirected Request (HTTP/2) | |
451 | ''' The request was directed at a server that Is Not able To produce a response (For example because a connection reuse).[18] |
452 | ''' </summary> |
453 | ''' <returns></returns> |
454 | Public ReadOnly Property RFC_MISDIRECTED_REQUEST As RequestStream |
455 | ''' <summary> |
456 | ''' 422 Unprocessable Entity (WebDAV; RFC 4918) | |
457 | ''' The request was well-formed but was unable To be followed due To semantic errors.[4] |
458 | ''' </summary> |
459 | ''' <returns></returns> |
460 | Public ReadOnly Property RFC_UNPROCESSABLE_ENTITY As RequestStream |
461 | ''' <summary> |
462 | ''' 423 Locked (WebDAV; RFC 4918) | |
463 | ''' The resource that Is being accessed Is locked.[4] |
464 | ''' </summary> |
465 | ''' <returns></returns> |
466 | Public ReadOnly Property RFC_LOCKED As RequestStream |
467 | ''' <summary> |
468 | ''' 424 Failed Dependency (WebDAV; RFC 4918) | |
469 | ''' The request failed due To failure Of a previous request (e.g., a PROPPATCH).[4] |
470 | ''' </summary> |
471 | ''' <returns></returns> |
472 | Public ReadOnly Property RFC_FAILED_DEPENDENCY As RequestStream |
473 | ''' <summary> |
474 | ''' 426 Upgrade Required | |
475 | ''' The client should switch To a different protocol such As TLS/1.0, given In the Upgrade header field. |
476 | ''' </summary> |
477 | ''' <returns></returns> |
478 | Public ReadOnly Property RFC_UPGRADE_REQUIRED As RequestStream |
479 | ''' <summary> |
480 | ''' 428 Precondition Required (RFC 6585) | |
481 | ''' The origin server requires the request To be conditional. Intended To prevent "the 'lost update' problem, |
482 | ''' where a client GETs a resource's state, modifies it, and PUTs it back to the server, when meanwhile a third party |
483 | ''' has modified the state on the server, leading to a conflict."[19] |
484 | ''' </summary> |
485 | ''' <returns></returns> |
486 | Public ReadOnly Property RFC_PRECONDITION_REQUIRED As RequestStream |
487 | ''' <summary> |
488 | ''' 429 Too Many Requests (RFC 6585) | |
489 | ''' The user has sent too many requests In a given amount Of time. Intended For use With rate limiting schemes.[19] |
490 | ''' </summary> |
491 | ''' <returns></returns> |
492 | Public ReadOnly Property RFC_TOO_MANY_REQUEST As RequestStream |
493 | ''' <summary> |
494 | ''' 431 Request Header Fields Too Large (RFC 6585) | |
495 | ''' The server Is unwilling To process the request because either an individual header field, Or all the header fields collectively, are too large.[19] |
496 | ''' </summary> |
497 | ''' <returns></returns> |
498 | Public ReadOnly Property RFC_REQUEST_HEADER_FIELDS_TOO_LARGE As RequestStream |
499 | ''' <summary> |
500 | ''' 440 Login Timeout (Microsoft) | |
501 | ''' A Microsoft extension. Indicates that your session has expired.[20] |
502 | ''' </summary> |
503 | ''' <returns></returns> |
504 | Public ReadOnly Property RFC_LOGIN_TIMEOUT As RequestStream |
505 | ''' <summary> |
506 | ''' 444 No Response (Nginx) | |
507 | ''' Used in Nginx logs to indicate that the server has returned no information to the client And closed the connection (useful as a deterrent for malware). |
508 | ''' </summary> |
509 | ''' <returns></returns> |
510 | Public ReadOnly Property RFC_NO_RESPONSE As RequestStream |
511 | ''' <summary> |
512 | ''' 449 Retry With (Microsoft) | |
513 | ''' A Microsoft extension. The request should be retried after performing the appropriate action.[21] |
514 | ''' </summary> |
515 | ''' <returns></returns> |
516 | Public ReadOnly Property RFC_RETRY_WITH As RequestStream |
517 | ''' <summary> |
518 | ''' 450 Blocked by Windows Parental Controls (Microsoft) | |
519 | ''' A Microsoft extension. This Error Is given When Windows Parental Controls are turned On And are blocking access To the given webpage.[22] |
520 | ''' </summary> |
521 | ''' <returns></returns> |
522 | Public ReadOnly Property RFC_BLOCKED As RequestStream |
523 | ''' <summary> |
524 | ''' 451 Unavailable For Legal Reasons (Internet draft) | |
525 | ''' Defined in the internet draft "A New HTTP Status Code for Legally-restricted Resources".[23] |
526 | ''' Intended to be used when resource access Is denied for legal reasons, e.g. censorship Or government-mandated blocked access. |
527 | ''' A reference to the 1953 dystopian novel Fahrenheit 451, where books are outlawed.[24] |
528 | ''' </summary> |
529 | ''' <returns></returns> |
530 | Public ReadOnly Property RFC_LEGAL_UNAVAILABLE As RequestStream |
531 | ''' <summary> |
532 | ''' 451 Redirect (Microsoft) | |
533 | ''' Used in Exchange ActiveSync if there either Is a more efficient server to use Or the server cannot access the users' mailbox.[25] |
534 | ''' The client Is supposed To re-run the HTTP Autodiscovery protocol To find a better suited server.[26] |
535 | ''' </summary> |
536 | ''' <returns></returns> |
537 | Public ReadOnly Property RFC_REDIRECT As RequestStream |
538 | ''' <summary> |
539 | ''' 494 Request Header Too Large (Nginx) | |
540 | ''' Nginx internal code similar To 431 but it was introduced earlier In version 0.9.4 (On January 21, 2011).[27][original research?] |
541 | ''' </summary> |
542 | ''' <returns></returns> |
543 | Public ReadOnly Property RFC_REQUEST_HEADER_TOO_LARGE As RequestStream |
544 | ''' <summary> |
545 | ''' 495 Cert Error (Nginx) | |
546 | ''' Nginx internal code used When SSL client certificate Error occurred To distinguish it from 4XX In a log And an Error page redirection. |
547 | ''' (在SSL层解密的时候错误,则为证书错误) |
548 | ''' </summary> |
549 | ''' <returns></returns> |
550 | Public ReadOnly Property RFC_CERT_ERROR As RequestStream |
551 | Get |
552 | Return New RequestStream(0, 495, "HTTP/495") |
553 | End Get |
554 | End Property |
555 | |
556 | ''' <summary> |
557 | ''' 496 No Cert (Nginx) | |
558 | ''' Nginx internal code used When client didn't provide certificate to distinguish it from 4XX in a log and an error page redirection. |
559 | ''' (客户端在向ssl服务器发送ssl请求的时候没有应用密匙加密,直接发送明文给服务器了,则服务器直接拒绝请求) |
560 | ''' </summary> |
561 | ''' <returns></returns> |
562 | Public ReadOnly Property RFC_NO_CERT As RequestStream = |
563 | New RequestStream(0, HTTP_RFC.RFC_NO_CERT, "HTTP/496") |
564 | |
565 | ''' <summary> |
566 | ''' 497 HTTP to HTTPS (Nginx) | |
567 | ''' Nginx internal code used For the plain HTTP requests that are sent To HTTPS port To distinguish it from 4XX In a log And an Error page redirection. |
568 | ''' </summary> |
569 | ''' <returns></returns> |
570 | Public ReadOnly Property RFC_HTTP_TO_HTTPS As RequestStream |
571 | ''' <summary> |
572 | ''' 498 Token expired/invalid (Esri) | |
573 | ''' Returned by ArcGIS For Server. A code Of 498 indicates an expired Or otherwise invalid token.[28] |
574 | ''' (错误的参数信息) |
575 | ''' </summary> |
576 | ''' <returns></returns> |
577 | Public ReadOnly Property RFC_TOKEN_INVALID As RequestStream |
578 | Get |
579 | Return New RequestStream(0, 498, "HTTP/498") |
580 | End Get |
581 | End Property |
582 | |
583 | ''' <summary> |
584 | ''' 499 Client Closed Request (Nginx) | |
585 | ''' Used in Nginx logs to indicate when the connection has been closed by client while the server Is still processing its request, making server unable to send a status code back.[29] |
586 | ''' </summary> |
587 | ''' <returns></returns> |
588 | Public ReadOnly Property RFC_CLOSED_REQUEST As RequestStream |
589 | ''' <summary> |
590 | ''' 499 Token required (Esri) | |
591 | ''' Returned by ArcGIS For Server. A code Of 499 indicates that a token Is required (If no token was submitted).[28] |
592 | ''' </summary> |
593 | ''' <returns></returns> |
594 | Public ReadOnly Property RFC_TOKEN_REQUIRED As RequestStream |
595 | |
596 | #End Region |
597 | |
598 | #Region "5xx Server Error" |
599 | |
600 | ''' <summary> |
601 | ''' 500 Internal Server Error | |
602 | ''' A generic Error message, given When an unexpected condition was encountered And no more specific message Is suitable. |
603 | ''' </summary> |
604 | ''' <returns></returns> |
605 | Public ReadOnly Property RFC_INTERNAL_SERVER_ERROR As RequestStream |
606 | Get |
607 | Return New RequestStream(0, 500, "HTTP/500") |
608 | End Get |
609 | End Property |
610 | |
611 | ''' <summary> |
612 | ''' 501 Not Implemented | |
613 | ''' The server either does Not recognize the request method, Or it lacks the ability To fulfill the request. Usually this implies future availability (e.g., a New feature Of a web-service API). |
614 | ''' </summary> |
615 | ''' <returns></returns> |
616 | Public ReadOnly Property RFC_NOT_IMPLEMENTED As RequestStream |
617 | Get |
618 | Return New RequestStream(0, 501, "HTTP/501") |
619 | End Get |
620 | End Property |
621 | |
622 | ''' <summary> |
623 | ''' 502 Bad Gateway | |
624 | ''' The server was acting As a gateway Or proxy And received an invalid response from the upstream server. |
625 | ''' </summary> |
626 | ''' <returns></returns> |
627 | Public ReadOnly Property RFC_BAD_GATEWAY As RequestStream = New RequestStream(0, HTTP_RFC.RFC_BAD_GATEWAY, "HTTP/502") |
628 | ''' <summary> |
629 | ''' 503 Service Unavailable | |
630 | ''' The server Is currently unavailable (because it Is overloaded Or down For maintenance). Generally, this Is a temporary state. |
631 | ''' </summary> |
632 | ''' <returns></returns> |
633 | Public ReadOnly Property RFC_SERVICE_UNAVAILABLE As RequestStream |
634 | Get |
635 | Return New RequestStream(0, 503, "HTTP/503") |
636 | End Get |
637 | End Property |
638 | |
639 | ''' <summary> |
640 | ''' 504 Gateway Timeout | |
641 | ''' The server was acting As a gateway Or proxy And did Not receive a timely response from the upstream server. |
642 | ''' </summary> |
643 | ''' <returns></returns> |
644 | Public ReadOnly Property RFC_GATEWAY_TIMEOUT As RequestStream |
645 | ''' <summary> |
646 | ''' 505 HTTP Version Not Supported | |
647 | ''' The server does Not support the HTTP protocol version used In the request. |
648 | ''' (服务器所不支持的协议类型) |
649 | ''' </summary> |
650 | ''' <returns></returns> |
651 | Public ReadOnly Property RFC_VERSION_NOT_SUPPORTED As RequestStream = |
652 | New RequestStream(0, HTTP_RFC.RFC_VERSION_NOT_SUPPORTED, "HTTP/505") |
653 | |
654 | ''' <summary> |
655 | ''' 506 Variant Also Negotiates (RFC 2295) | |
656 | ''' Transparent content negotiation For the request results In a circular reference.[30] |
657 | ''' </summary> |
658 | ''' <returns></returns> |
659 | Public ReadOnly Property RFC_NEGOTIATES As RequestStream |
660 | ''' <summary> |
661 | ''' 507 Insufficient Storage (WebDAV; RFC 4918) | |
662 | ''' The server Is unable To store the representation needed To complete the request.[4] |
663 | ''' </summary> |
664 | ''' <returns></returns> |
665 | Public ReadOnly Property RFC_INSUFFICIENT_STORAGE As RequestStream |
666 | ''' <summary> |
667 | ''' 508 Loop Detected (WebDAV; RFC 5842) | |
668 | ''' The server detected an infinite Loop While processing the request (sent In lieu Of 208 Already Reported). |
669 | ''' </summary> |
670 | ''' <returns></returns> |
671 | Public ReadOnly Property RFC_LOOP_DETECTED As RequestStream |
672 | ''' <summary> |
673 | ''' 509 Bandwidth Limit Exceeded (Apache bw/limited extension)[31] | |
674 | ''' This status code Is Not specified In any RFCs. Its use Is unknown. |
675 | ''' </summary> |
676 | ''' <returns></returns> |
677 | Public ReadOnly Property RFC_BANDWIDTH_LIMITED_EXCEEDED As RequestStream |
678 | ''' <summary> |
679 | ''' 510 Not Extended (RFC 2774) | |
680 | ''' Further extensions To the request are required For the server To fulfil it.[32] |
681 | ''' </summary> |
682 | ''' <returns></returns> |
683 | Public ReadOnly Property RFC_NOT_EXTENDED As RequestStream |
684 | ''' <summary> |
685 | ''' 511 Network Authentication Required (RFC 6585) | |
686 | ''' The client needs To authenticate To gain network access. Intended For use by intercepting proxies used To control access To the network |
687 | ''' (e.g., "captive portals" used To require agreement To Terms Of Service before granting full Internet access via a Wi-Fi hotspot).[19] |
688 | ''' </summary> |
689 | ''' <returns></returns> |
690 | Public ReadOnly Property RFC_NETWORK_AUTH_REQUIRED As RequestStream |
691 | ''' <summary> |
692 | ''' 520 Unknown Error | |
693 | ''' This status code Is Not specified In any RFC And Is returned by certain services, For instance Microsoft Azure And CloudFlare servers: |
694 | ''' "The 520 error is essentially a “catch-all” response for when the origin server returns something unexpected or something that is not |
695 | ''' tolerated/interpreted (protocol violation or empty response)."[33] |
696 | ''' </summary> |
697 | ''' <returns></returns> |
698 | Public ReadOnly Property RFC_UNKNOWN_ERROR As RequestStream |
699 | Get |
700 | Return New RequestStream(0, 520, "HTTP/520") |
701 | End Get |
702 | End Property |
703 | |
704 | ''' <summary> |
705 | ''' 522 Origin Connection Time-out | |
706 | ''' This status code Is Not specified In any RFCs, but Is used by CloudFlare's reverse proxies to signal that a server connection timed out. |
707 | ''' </summary> |
708 | ''' <returns></returns> |
709 | Public ReadOnly Property RFC_CONNECTION_TIMEOUT As RequestStream |
710 | ''' <summary> |
711 | ''' 598 Network read timeout error (Unknown) | |
712 | ''' This status code Is Not specified In any RFCs, but Is used by Microsoft HTTP proxies To signal a network read timeout behind the proxy To a client In front Of the proxy.[citation needed] |
713 | ''' </summary> |
714 | ''' <returns></returns> |
715 | Public ReadOnly Property RFC_READ_TIMEOUT_ERROR As RequestStream |
716 | ''' <summary> |
717 | ''' 599 Network connect timeout error (Unknown) | |
718 | ''' This status code Is Not specified In any RFCs, but Is used by Microsoft HTTP proxies To signal a network connect timeout behind the proxy To a client In front Of the proxy.[citation needed] |
719 | ''' </summary> |
720 | ''' <returns></returns> |
721 | Public ReadOnly Property RFC_CONNECT_TIMEOUT_ERROR As RequestStream |
722 | #End Region |
723 | |
724 | ''' <summary> |
725 | ''' 服务器所返回来的数据是否为HTTP错误代码 |
726 | ''' </summary> |
727 | ''' <param name="response"></param> |
728 | ''' <returns></returns> |
729 | <Extension> Public Function IsHTTP_RFC(response As RequestStream) As Boolean |
730 | Dim data As String = response.GetUTF8String |
731 | Dim isHTTP As Boolean = String.Equals(Regex.Match(data, "HTTP[/]\d{3}").Value, data) |
732 | Return isHTTP AndAlso response.Protocol <> HTTP_RFC.RFC_OK |
733 | End Function |
734 | End Module |
735 | End Namespace |