/
http_predicates.clj
426 lines (356 loc) · 10.2 KB
/
http_predicates.clj
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
(ns ring.util.http-predicates)
(defn informational?
"Check whether the response type is Informational (status code is between
100 and 199)."
[response]
{:pre (map? response)}
(<= 100 (:status response) 199))
(defn success?
"Check whether the response type is Success (status code is between
200 and 299)."
[response]
{:pre (map? response)}
(<= 200 (:status response) 299))
(defn redirection?
"Check whether the response type is Redirection (status code is between
300 and 399)."
[response]
{:pre (map? response)}
(<= 300 (:status response) 399))
(defn client-error?
"Check whether the response type is ClientError (status code is between
400 and 499)."
[response]
{:pre (map? response)}
(<= 400 (:status response) 499))
(defn server-error?
"Check whether the response type is ServerError (status code is between
500 and 599)."
[response]
{:pre (map? response)}
(<= 500 (:status response) 599))
(defn continue?
"Checks whether the response has status code 100"
[response]
{:pre (map? response)}
(= (:status response) 100))
(defn switching-protocols?
"Checks whether the response has status code 101"
[response]
{:pre (map? response)}
(= (:status response) 101))
(defn processing?
"Checks whether the response has status code 102"
[response]
{:pre (map? response)}
(= (:status response) 102))
(defn ok?
"Checks whether the response has status code 200"
[response]
{:pre (map? response)}
(= (:status response) 200))
(defn created?
"Checks whether the response has status code 201"
[response]
{:pre (map? response)}
(= (:status response) 201))
(defn accepted?
"Checks whether the response has status code 202"
[response]
{:pre (map? response)}
(= (:status response) 202))
(defn non-authoritative-information?
"Checks whether the response has status code 203"
[response]
{:pre (map? response)}
(= (:status response) 203))
(defn no-content?
"Checks whether the response has status code 204"
[response]
{:pre (map? response)}
(= (:status response) 204))
(defn reset-content?
"Checks whether the response has status code 205"
[response]
{:pre (map? response)}
(= (:status response) 205))
(defn partial-content?
"Checks whether the response has status code 206"
[response]
{:pre (map? response)}
(= (:status response) 206))
(defn multi-status?
"Checks whether the response has status code 207"
[response]
{:pre (map? response)}
(= (:status response) 207))
(defn already-reported?
"Checks whether the response has status code 208"
[response]
{:pre (map? response)}
(= (:status response) 208))
(defn im-used?
"Checks whether the response has status code 226"
[response]
{:pre (map? response)}
(= (:status response) 226))
(defn multiple-choices?
"Checks whether the response has status code 300"
[response]
{:pre (map? response)}
(= (:status response) 300))
(defn moved-permanently?
"Checks whether the response has status code 301"
[response]
{:pre (map? response)}
(= (:status response) 301))
(defn found?
"Checks whether the response has status code 302"
[response]
{:pre (map? response)}
(= (:status response) 302))
(defn see-other?
"Checks whether the response has status code 303"
[response]
{:pre (map? response)}
(= (:status response) 303))
(defn not-modified?
"Checks whether the response has status code 304"
[response]
{:pre (map? response)}
(= (:status response) 304))
(defn use-proxy?
"Checks whether the response has status code 305"
[response]
{:pre (map? response)}
(= (:status response) 305))
(defn temporary-redirect?
"Checks whether the response has status code 307"
[response]
{:pre (map? response)}
(= (:status response) 307))
(defn permanent-redirect?
"Checks whether the response has status code 308"
[response]
{:pre (map? response)}
(= (:status response) 308))
(defn bad-request?
"Checks whether the response has status code 400"
[response]
{:pre (map? response)}
(= (:status response) 400))
(defn unauthorized?
"Checks whether the response has status code 401"
[response]
{:pre (map? response)}
(= (:status response) 401))
(defn payment-required?
"Checks whether the response has status code 402"
[response]
{:pre (map? response)}
(= (:status response) 402))
(defn forbidden?
"Checks whether the response has status code 403"
[response]
{:pre (map? response)}
(= (:status response) 403))
(defn not-found?
"Checks whether the response has status code 404"
[response]
{:pre (map? response)}
(= (:status response) 404))
(defn method-not-allowed?
"Checks whether the response has status code 405"
[response]
{:pre (map? response)}
(= (:status response) 405))
(defn not-acceptable?
"Checks whether the response has status code 406"
[response]
{:pre (map? response)}
(= (:status response) 406))
(defn proxy-authentication-required?
"Checks whether the response has status code 407"
[response]
{:pre (map? response)}
(= (:status response) 407))
(defn request-timeout?
"Checks whether the response has status code 408"
[response]
{:pre (map? response)}
(= (:status response) 408))
(defn conflict?
"Checks whether the response has status code 409"
[response]
{:pre (map? response)}
(= (:status response) 409))
(defn gone?
"Checks whether the response has status code 410"
[response]
{:pre (map? response)}
(= (:status response) 410))
(defn length-required?
"Checks whether the response has status code 411"
[response]
{:pre (map? response)}
(= (:status response) 411))
(defn precondition-failed?
"Checks whether the response has status code 412"
[response]
{:pre (map? response)}
(= (:status response) 412))
(defn request-entity-too-large?
"Checks whether the response has status code 413"
[response]
{:pre (map? response)}
(= (:status response) 413))
(defn request-uri-too-long?
"Checks whether the response has status code 414"
[response]
{:pre (map? response)}
(= (:status response) 414))
(defn unsupported-media-type?
"Checks whether the response has status code 415"
[response]
{:pre (map? response)}
(= (:status response) 415))
(defn requested-range-not-satisfiable?
"Checks whether the response has status code 416"
[response]
{:pre (map? response)}
(= (:status response) 416))
(defn expectation-failed?
"Checks whether the response has status code 417"
[response]
{:pre (map? response)}
(= (:status response) 417))
(defn enhance-your-calm?
"Checks whether the response has status code 420"
[response]
{:pre (map? response)}
(= (:status response) 420))
(defn unprocessable-entity?
"Checks whether the response has status code 422"
[response]
{:pre (map? response)}
(= (:status response) 422))
(defn locked?
"Checks whether the response has status code 423"
[response]
{:pre (map? response)}
(= (:status response) 423))
(defn failed-dependency?
"Checks whether the response has status code 424"
[response]
{:pre (map? response)}
(= (:status response) 424))
(defn unordered-collection?
"Checks whether the response has status code 425"
[response]
{:pre (map? response)}
(= (:status response) 425))
(defn upgrade-required?
"Checks whether the response has status code 426"
[response]
{:pre (map? response)}
(= (:status response) 426))
(defn precondition-required?
"Checks whether the response has status code 428"
[response]
{:pre (map? response)}
(= (:status response) 428))
(defn too-many-requests?
"Checks whether the response has status code 429"
[response]
{:pre (map? response)}
(= (:status response) 429))
(defn request-header-fields-too-large?
"Checks whether the response has status code 431"
[response]
{:pre (map? response)}
(= (:status response) 431))
(defn retry-with?
"Checks whether the response has status code 449"
[response]
{:pre (map? response)}
(= (:status response) 449))
(defn blocked-by-windows-parental-controls?
"Checks whether the response has status code 450"
[response]
{:pre (map? response)}
(= (:status response) 450))
(defn unavailable-for-legal-reasons?
"Checks whether the response has status code 451"
[response]
{:pre (map? response)}
(= (:status response) 451))
(defn internal-server-error?
"Checks whether the response has status code 500"
[response]
{:pre (map? response)}
(= (:status response) 500))
(defn not-implemented?
"Checks whether the response has status code 501"
[response]
{:pre (map? response)}
(= (:status response) 501))
(defn bad-gateway?
"Checks whether the response has status code 502"
[response]
{:pre (map? response)}
(= (:status response) 502))
(defn service-unavailable?
"Checks whether the response has status code 503"
[response]
{:pre (map? response)}
(= (:status response) 503))
(defn gateway-timeout?
"Checks whether the response has status code 504"
[response]
{:pre (map? response)}
(= (:status response) 504))
(defn http-version-not-supported?
"Checks whether the response has status code 505"
[response]
{:pre (map? response)}
(= (:status response) 505))
(defn variant-also-negotiates?
"Checks whether the response has status code 506"
[response]
{:pre (map? response)}
(= (:status response) 506))
(defn insufficient-storage?
"Checks whether the response has status code 507"
[response]
{:pre (map? response)}
(= (:status response) 507))
(defn loop-detected?
"Checks whether the response has status code 508"
[response]
{:pre (map? response)}
(= (:status response) 508))
(defn bandwidth-limit-exceeded?
"Checks whether the response has status code 509"
[response]
{:pre (map? response)}
(= (:status response) 509))
(defn not-extended?
"Checks whether the response has status code 510"
[response]
{:pre (map? response)}
(= (:status response) 510))
(defn network-authentication-required?
"Checks whether the response has status code 511"
[response]
{:pre (map? response)}
(= (:status response) 511))
(defn network-read-timeout?
"Checks whether the response has status code 598"
[response]
{:pre (map? response)}
(= (:status response) 598))
(defn network-connect-timeout?
"Checks whether the response has status code 599"
[response]
{:pre (map? response)}
(= (:status response) 599))