Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/third_party/closure/goog/net/httpstatus.js
2868 views
1
// Copyright 2011 The Closure Library Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS-IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
/**
16
* @fileoverview Constants for HTTP status codes.
17
*/
18
19
goog.provide('goog.net.HttpStatus');
20
21
22
/**
23
* HTTP Status Codes defined in RFC 2616 and RFC 6585.
24
* @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
25
* @see http://tools.ietf.org/html/rfc6585
26
* @enum {number}
27
*/
28
goog.net.HttpStatus = {
29
// Informational 1xx
30
CONTINUE: 100,
31
SWITCHING_PROTOCOLS: 101,
32
33
// Successful 2xx
34
OK: 200,
35
CREATED: 201,
36
ACCEPTED: 202,
37
NON_AUTHORITATIVE_INFORMATION: 203,
38
NO_CONTENT: 204,
39
RESET_CONTENT: 205,
40
PARTIAL_CONTENT: 206,
41
42
// Redirection 3xx
43
MULTIPLE_CHOICES: 300,
44
MOVED_PERMANENTLY: 301,
45
FOUND: 302,
46
SEE_OTHER: 303,
47
NOT_MODIFIED: 304,
48
USE_PROXY: 305,
49
TEMPORARY_REDIRECT: 307,
50
51
// Client Error 4xx
52
BAD_REQUEST: 400,
53
UNAUTHORIZED: 401,
54
PAYMENT_REQUIRED: 402,
55
FORBIDDEN: 403,
56
NOT_FOUND: 404,
57
METHOD_NOT_ALLOWED: 405,
58
NOT_ACCEPTABLE: 406,
59
PROXY_AUTHENTICATION_REQUIRED: 407,
60
REQUEST_TIMEOUT: 408,
61
CONFLICT: 409,
62
GONE: 410,
63
LENGTH_REQUIRED: 411,
64
PRECONDITION_FAILED: 412,
65
REQUEST_ENTITY_TOO_LARGE: 413,
66
REQUEST_URI_TOO_LONG: 414,
67
UNSUPPORTED_MEDIA_TYPE: 415,
68
REQUEST_RANGE_NOT_SATISFIABLE: 416,
69
EXPECTATION_FAILED: 417,
70
PRECONDITION_REQUIRED: 428,
71
TOO_MANY_REQUESTS: 429,
72
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
73
74
// Server Error 5xx
75
INTERNAL_SERVER_ERROR: 500,
76
NOT_IMPLEMENTED: 501,
77
BAD_GATEWAY: 502,
78
SERVICE_UNAVAILABLE: 503,
79
GATEWAY_TIMEOUT: 504,
80
HTTP_VERSION_NOT_SUPPORTED: 505,
81
NETWORK_AUTHENTICATION_REQUIRED: 511,
82
83
/*
84
* IE returns this code for 204 due to its use of URLMon, which returns this
85
* code for 'Operation Aborted'. The status text is 'Unknown', the response
86
* headers are ''. Known to occur on IE 6 on XP through IE9 on Win7.
87
*/
88
QUIRK_IE_NO_CONTENT: 1223
89
};
90
91
92
/**
93
* Returns whether the given status should be considered successful.
94
*
95
* Successful codes are OK (200), CREATED (201), ACCEPTED (202),
96
* NO CONTENT (204), PARTIAL CONTENT (206), NOT MODIFIED (304),
97
* and IE's no content code (1223).
98
*
99
* @param {number} status The status code to test.
100
* @return {boolean} Whether the status code should be considered successful.
101
*/
102
goog.net.HttpStatus.isSuccess = function(status) {
103
switch (status) {
104
case goog.net.HttpStatus.OK:
105
case goog.net.HttpStatus.CREATED:
106
case goog.net.HttpStatus.ACCEPTED:
107
case goog.net.HttpStatus.NO_CONTENT:
108
case goog.net.HttpStatus.PARTIAL_CONTENT:
109
case goog.net.HttpStatus.NOT_MODIFIED:
110
case goog.net.HttpStatus.QUIRK_IE_NO_CONTENT:
111
return true;
112
113
default:
114
return false;
115
}
116
};
117
118