Repository navigation
Expand file tree
/
Copy pathHttpStatus.js
More file actions
277 lines (274 loc) · 11.6 KB
/
Copy pathHttpStatus.js
File metadata and controls
277 lines (274 loc) · 11.6 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/**
* Service to wrap some generic HTTP status helper methods. Currently this service has
* following methods available:
*
* HttpStatus.getText(httpStatusCode);
*
* @todo add more these helpers :D
*/
(function() {
'use strict';
angular.module('Taskboard.services')
.factory('HttpStatus', function() {
return {
/**
* Getter method for HTTP status message by given status code.
*
* @param {Number} statusCode HTTP status code
*
* @returns {String} Status message
*/
getText: function(statusCode) {
var output = 'Unknown';
switch (statusCode) {
// 1xx Informational
case 100:
output = 'Continue';
break;
case 101:
output = 'Switching Protocols';
break;
case 102:
output = 'Processing (WebDAV; RFC 2518)';
break;
// 2xx Success
case 200:
output = 'OK';
break;
case 201:
output = 'Created';
break;
case 202:
output = 'Accepted';
break;
case 203:
output = 'Non-Authoritative Information (since HTTP/1.1)';
break;
case 204:
output = 'No Content';
break;
case 205:
output = 'Reset Content';
break;
case 206:
output = 'Partial Content';
break;
case 207:
output = 'Multi-Status (WebDAV; RFC 4918)';
break;
case 208:
output = 'Already Reported (WebDAV; RFC 5842)';
break;
case 226:
output = 'IM Used (RFC 3229)';
break;
// 3xx Redirection
case 300:
output = 'Multiple Choices';
break;
case 301:
output = 'Moved Permanently';
break;
case 302:
output = 'Found';
break;
case 303:
output = 'See Other';
break;
case 304:
output = 'Not Modified';
break;
case 305:
output = 'Use Proxy';
break;
case 306:
output = 'Switch Proxy';
break;
case 307:
output = 'Temporary Redirect';
break;
case 308:
output = 'Permanent Redirect (Experimental RFC; RFC 7238)';
break;
// 4xx Client Error
case 400:
output = 'Bad Request';
break;
case 401:
output = 'Unauthorized';
break;
case 402:
output = 'Payment Required';
break;
case 403:
output = 'Forbidden';
break;
case 404:
output = 'Not Found';
break;
case 405:
output = 'Method Not Allowed';
break;
case 406:
output = 'Not Acceptable';
break;
case 407:
output = 'Proxy Authentication Required';
break;
case 408:
output = 'Request Timeout';
break;
case 409:
output = 'Conflict';
break;
case 410:
output = 'Gone';
break;
case 411:
output = 'Length Required';
break;
case 412:
output = 'Precondition Failed';
break;
case 413:
output = 'Request Entity Too Large';
break;
case 414:
output = 'Request-URI Too Long';
break;
case 415:
output = 'Unsupported Media Type';
break;
case 416:
output = 'Requested Range Not Satisfiable';
break;
case 417:
output = 'Expectation Failed';
break;
case 418:
output = 'I\'m a teapot (RFC 2324)';
break;
case 419:
output = 'Authentication Timeout (not in RFC 2616)';
break;
case 420:
output = 'Method Failure (Spring Framework) / Enhance Your Calm (Twitter)';
break;
case 422:
output = 'Unprocessable Entity (WebDAV; RFC 4918)';
break;
case 423:
output = 'Locked (WebDAV; RFC 4918)';
break;
case 424:
output = 'Failed Dependency (WebDAV; RFC 4918)';
break;
case 426:
output = 'Upgrade Required';
break;
case 428:
output = 'Precondition Required (RFC 6585)';
break;
case 429:
output = 'Too Many Requests (RFC 6585)';
break;
case 431:
output = 'Request Header Fields Too Large (RFC 6585)';
break;
case 440:
output = 'Login Timeout (Microsoft)';
break;
case 444:
output = 'No Response (Nginx)';
break;
case 449:
output = 'Retry With (Microsoft)';
break;
case 450:
output = 'Blocked by Windows Parental Controls (Microsoft)';
break;
case 451:
output = 'Unavailable For Legal Reasons (Internet draft) / Redirect (Microsoft)';
break;
case 494:
output = 'Request Header Too Large (Nginx)';
break;
case 495:
output = 'Cert Error (Nginx)';
break;
case 496:
output = 'No Cert (Nginx)';
break;
case 497:
output = 'HTTP to HTTPS (Nginx)';
break;
case 498:
output = 'Token expired/invalid (Esri)';
break;
case 499:
output = 'Client Closed Request (Nginx) / Token required (Esri)';
break;
// 5xx Server Error
case 500:
output = 'Internal Server Error';
break;
case 501:
output = 'Not Implemented';
break;
case 502:
output = 'Bad Gateway';
break;
case 503:
output = 'Service Unavailable';
break;
case 504:
output = 'Gateway Timeout';
break;
case 505:
output = 'HTTP Version Not Supported';
break;
case 506:
output = 'Variant Also Negotiates (RFC 2295)';
break;
case 507:
output = 'Insufficient Storage (WebDAV; RFC 4918)';
break;
case 508:
output = 'Loop Detected (WebDAV; RFC 5842)';
break;
case 509:
output = 'Bandwidth Limit Exceeded (Apache bw/limited extension)';
break;
case 510:
output = 'Not Extended (RFC 2774)';
break;
case 511:
output = 'Network Authentication Required (RFC 6585)';
break;
case 520:
output = 'Origin Error (Cloudflare)';
break;
case 521:
output = 'Web server is down (Cloudflare)';
break;
case 522:
output = 'Connection timed out (Cloudflare)';
break;
case 523:
output = 'Proxy Declined Request (Cloudflare)';
break;
case 524:
output = 'A timeout occurred (Cloudflare)';
break;
case 598:
output = 'Network read timeout error (Unknown)';
break;
case 599:
output = 'Network connect timeout error (Unknown)';
break;
}
return output;
}
};
});
}());