-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathTeapotStatusCodeMetadataCollection.cs
More file actions
371 lines (363 loc) · 10.9 KB
/
Copy pathTeapotStatusCodeMetadataCollection.cs
File metadata and controls
371 lines (363 loc) · 10.9 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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
using System;
using System.Collections.Generic;
using Teapot.Web.Models.Unofficial;
namespace Teapot.Web.Models;
public class TeapotStatusCodeMetadataCollection : Dictionary<int, TeapotStatusCodeMetadata>
{
public TeapotStatusCodeMetadataCollection(
AmazonStatusCodeMetadata amazon,
CloudflareStatusCodeMetadata cloudflare,
EsriStatusCodeMetadata esri,
LaravelStatusCodeMetadata laravel,
MicrosoftStatusCodeMetadata microsoft,
NginxStatusCodeMetadata nginx,
TwitterStatusCodeMetadata twitter)
{
// 1xx range
Add(100, new TeapotStatusCodeMetadata
{
Description = "Continue",
ExcludeBody = true
});
Add(101, new TeapotStatusCodeMetadata
{
Description = "Switching Protocols",
ExcludeBody = true
});
Add(102, new TeapotStatusCodeMetadata
{
Description = "Processing",
ExcludeBody = true
});
Add(103, new TeapotStatusCodeMetadata
{
Description = "Early Hints",
ExcludeBody = true,
IncludeHeaders = new Dictionary<string, string>
{
{"Link", "</css/main.css>; rel=preload"}
}
});
// 2xx range
Add(200, new TeapotStatusCodeMetadata
{
Description = "OK",
});
Add(201, new TeapotStatusCodeMetadata
{
Description = "Created",
});
Add(202, new TeapotStatusCodeMetadata
{
Description = "Accepted"
});
Add(203, new TeapotStatusCodeMetadata
{
Description = "Non-Authoritative Information"
});
Add(204, new TeapotStatusCodeMetadata
{
Description = "No Content",
ExcludeBody = true
});
Add(205, new TeapotStatusCodeMetadata
{
Description = "Reset Content",
ExcludeBody = true
});
Add(206, new TeapotStatusCodeMetadata
{
Description = "Partial Content",
IncludeHeaders = new Dictionary<string, string>
{
{"Content-Range", "0-30"}
}
});
Add(207, new TeapotStatusCodeMetadata
{
Description = "Multi-Status",
IncludeHeaders = new Dictionary<string, string>
{
{ "Content-Type", "application/xml; charset=\"utf-8\"" }
},
Link = new Uri("https://tools.ietf.org/html/rfc4918"),
Body = """
<?xml version="1.0" encoding="utf-8"?>
<d:multistatus xmlns:d="DAV:">
<d:response>
<d:href>http://www.example.com/container/resource3</d:href>
<d:status>HTTP/1.1 423 Locked</d:status>
<d:error><d:lock-token-submitted/></d:error>
</d:response>
</d:multistatus>
"""
});
Add(208, new TeapotStatusCodeMetadata
{
Description = "Already Reported"
});
Add(226, new TeapotStatusCodeMetadata
{
Description = "IM Used",
Link = new Uri("https://tools.ietf.org/html/rfc3229#section-10.4.1")
});
// 3xx range
Add(300, new TeapotStatusCodeMetadata
{
Description = "Multiple Choices"
});
Add(301, new TeapotStatusCodeMetadata
{
Description = "Moved Permanently",
IncludeHeaders = new Dictionary<string, string>
{
{"Location", "https://httpstat.us"},
{"Retry-After", "5"}
}
});
Add(302, new TeapotStatusCodeMetadata
{
Description = "Found",
IncludeHeaders = new Dictionary<string, string>
{
{"Location", "https://httpstat.us/"}
}
});
Add(303, new TeapotStatusCodeMetadata
{
Description = "See Other",
IncludeHeaders = new Dictionary<string, string>
{
{"Location", "https://httpstat.us/"}
}
});
Add(304, new TeapotStatusCodeMetadata
{
Description = "Not Modified",
ExcludeBody = true
});
Add(305, new TeapotStatusCodeMetadata
{
Description = "Use Proxy",
IncludeHeaders = new Dictionary<string, string>
{
{"Location", "https://httpstat.us/"}
}
});
Add(306, new TeapotStatusCodeMetadata
{
Description = "Switch Proxy"
});
Add(307, new TeapotStatusCodeMetadata
{
Description = "Temporary Redirect",
IncludeHeaders = new Dictionary<string, string>
{
{"Location", "https://httpstat.us/"}
}
});
Add(308, new TeapotStatusCodeMetadata
{
Description = "Permanent Redirect",
IncludeHeaders = new Dictionary<string, string>
{
{"Location", "https://httpstat.us/"}
}
});
// 4xx
Add(400, new TeapotStatusCodeMetadata
{
Description = "Bad Request"
});
Add(401, new TeapotStatusCodeMetadata
{
Description = "Unauthorized",
IncludeHeaders = new Dictionary<string, string>
{
{"WWW-Authenticate", "Basic realm=\"Fake Realm\""}
}
});
Add(402, new TeapotStatusCodeMetadata
{
Description = "Payment Required"
});
Add(403, new TeapotStatusCodeMetadata
{
Description = "Forbidden"
});
Add(404, new TeapotStatusCodeMetadata
{
Description = "Not Found"
});
Add(405, new TeapotStatusCodeMetadata
{
Description = "Method Not Allowed"
});
Add(406, new TeapotStatusCodeMetadata
{
Description = "Not Acceptable"
});
Add(407, new TeapotStatusCodeMetadata
{
Description = "Proxy Authentication Required",
IncludeHeaders = new Dictionary<string, string>
{
{"Proxy-Authenticate", "Basic realm=\"Fake Realm\""}
}
});
Add(408, new TeapotStatusCodeMetadata
{
Description = "Request Timeout"
});
Add(409, new TeapotStatusCodeMetadata
{
Description = "Conflict"
});
Add(410, new TeapotStatusCodeMetadata
{
Description = "Gone"
});
Add(411, new TeapotStatusCodeMetadata
{
Description = "Length Required"
});
Add(412, new TeapotStatusCodeMetadata
{
Description = "Precondition Failed"
});
Add(413, new TeapotStatusCodeMetadata
{
Description = "Request Entity Too Large"
});
Add(414, new TeapotStatusCodeMetadata
{
Description = "Request-URI Too Long"
});
Add(415, new TeapotStatusCodeMetadata
{
Description = "Unsupported Media Type"
});
Add(416, new TeapotStatusCodeMetadata
{
Description = "Requested Range Not Satisfiable"
});
Add(417, new TeapotStatusCodeMetadata
{
Description = "Expectation Failed"
});
Add(418, new TeapotStatusCodeMetadata
{
Description = "I'm a teapot",
Link = new Uri("https://www.ietf.org/rfc/rfc2324.txt")
});
Add(421, new TeapotStatusCodeMetadata
{
Description = "Misdirected Request"
});
Add(422, new TeapotStatusCodeMetadata
{
Description = "Unprocessable Entity"
});
Add(423, new TeapotStatusCodeMetadata
{
Description = "Locked"
});
Add(424, new TeapotStatusCodeMetadata
{
Description = "Failed Dependency"
});
Add(425, new TeapotStatusCodeMetadata
{
Description = "Too Early"
});
Add(426, new TeapotStatusCodeMetadata
{
Description = "Upgrade Required"
});
Add(428, new TeapotStatusCodeMetadata
{
Description = "Precondition Required"
});
Add(429, new TeapotStatusCodeMetadata
{
Description = "Too Many Requests",
IncludeHeaders = new Dictionary<string, string>
{
{"Retry-After", "5"}
}
});
Add(431, new TeapotStatusCodeMetadata
{
Description = "Request Header Fields Too Large"
});
Add(451, new TeapotStatusCodeMetadata
{
Description = "Unavailable For Legal Reasons"
});
// 5xx
Add(500, new TeapotStatusCodeMetadata
{
Description = "Internal Server Error"
});
Add(501, new TeapotStatusCodeMetadata
{
Description = "Not Implemented"
});
Add(502, new TeapotStatusCodeMetadata
{
Description = "Bad Gateway"
});
Add(503, new TeapotStatusCodeMetadata
{
Description = "Service Unavailable",
IncludeHeaders = new Dictionary<string, string>
{
{"Retry-After", "5"}
}
});
Add(504, new TeapotStatusCodeMetadata
{
Description = "Gateway Timeout"
});
Add(505, new TeapotStatusCodeMetadata
{
Description = "HTTP Version Not Supported"
});
Add(506, new TeapotStatusCodeMetadata
{
Description = "Variant Also Negotiates"
});
Add(507, new TeapotStatusCodeMetadata
{
Description = "Insufficient Storage"
});
Add(508, new TeapotStatusCodeMetadata
{
Description = "Loop Detected",
Link = new Uri("https://tools.ietf.org/html/rfc5842")
});
Add(510, new TeapotStatusCodeMetadata
{
Description = "Not Extended",
Link = new Uri("https://tools.ietf.org/html/rfc2774")
});
Add(511, new TeapotStatusCodeMetadata
{
Description = "Network Authentication Required"
});
AddNonStandardStatusCodes(amazon);
AddNonStandardStatusCodes(cloudflare);
AddNonStandardStatusCodes(esri);
AddNonStandardStatusCodes(laravel);
AddNonStandardStatusCodes(microsoft);
AddNonStandardStatusCodes(nginx);
AddNonStandardStatusCodes(twitter);
}
private void AddNonStandardStatusCodes(IDictionary<int, TeapotStatusCodeMetadata> codes)
{
foreach (var item in codes)
{
Add(item.Key, item.Value);
}
}
}