Terarea  2
The automation project
Loading...
Searching...
No Matches
http_codes.py
Go to the documentation of this file.
7
8import json
9from typing import Mapping, Union, Dict, Any
10from fastapi import Response
11
12
14 """_summary_
15 A class containing all the known http codes that can be used to reply to websites.
16 These codes are:
17 * The 1xx: Continue
18 * The 2xx: Success
19 * The 3xx: Redirection
20 * The 4xx: Client error
21 * The 5xx: Server error
22 """
23
24 def __init__(self) -> None:
26 100, 101, 102, 103, 110,
27 200, 201, 202, 203, 204, 205,
28 206, 207, 208, 226,
29 300, 301, 302, 303, 304, 305,
30 306, 307, 308,
31 400, 401, 402, 403, 404, 405,
32 406, 407, 408, 409, 410, 411,
33 412, 413, 414, 415, 416, 417,
34 418, 419, 420, 421, 422, 423,
35 424, 425, 426, 428, 429, 430,
36 431, 451, 498,
37 500, 501, 502, 503, 504, 505,
38 506, 507, 508, 509, 510, 511
39 ]
40 self.data_types = {
41 'json': 'application/json',
42 'html': 'text/html',
43 'text': 'text/plain',
44 'xml': 'application/xml',
45 'css': 'text/css',
46 'javascript': 'application/javascript',
47 'js': 'application/javascript',
48 'form': 'application/x-www-form-urlencoded',
49 'form-data': 'multipart/form-data',
50 'jpeg': 'image/jpeg',
51 'jpg': 'image/jpeg',
52 'png': 'image/png',
53 'gif': 'image/gif',
54 'bmp': 'image/bmp',
55 'tiff': 'image/tiff',
56 'webp': 'image/webp',
57 'pdf': 'application/pdf',
58 'zip': 'application/zip',
59 'gzip': 'application/gzip',
60 'octet-stream': 'application/octet-stream',
61 'csv': 'text/csv',
62 'plain': 'text/plain',
63 'mp3': 'audio/mpeg',
64 'mp4': 'video/mp4',
65 'mpeg': 'video/mpeg',
66 'avi': 'video/x-msvideo',
67 'webm': 'video/webm',
68 'ogg': 'application/ogg',
69 'jsonld': 'application/ld+json',
70 'markdown': 'text/markdown',
71 'md': 'text/markdown',
72 'rtf': 'application/rtf',
73 'wav': 'audio/wav',
74 'flac': 'audio/flac',
75 'aac': 'audio/aac',
76 'ogg-audio': 'audio/ogg',
77 'opus': 'audio/opus',
78 '3gp': 'video/3gpp',
79 '3gpp': 'video/3gpp',
80 '3g2': 'video/3gpp2',
81 '3gpp2': 'video/3gpp2',
82 'tar': 'application/x-tar',
83 'ico': 'image/vnd.microsoft.icon',
84 'svg': 'image/svg+xml',
85 'txt': 'text/plain',
86 'doc': 'application/msword',
87 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
88 'xls': 'application/vnd.ms-excel',
89 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
90 'ppt': 'application/vnd.ms-powerpoint',
91 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
92 'eot': 'application/vnd.ms-fontobject',
93 'otf': 'font/otf',
94 'ttf': 'font/ttf',
95 'woff': 'font/woff',
96 'woff2': 'font/woff2'
97 }
98
99 # """ General basic success message that speaks on channel 200 by default """
100
101 def _check_data_type(self, data_type: Union[str, None] = None) -> str:
102 """_summary_
103 Function in charge of checking the type provided by the user is one that can be used to send data.
104
105 Args:
106 data_type (str, optional): _description_. Defaults to None.
107
108 Returns:
109 str: _description_: Returns the correct known version of the sent data.
110 """
111 if data_type is None:
112 return "text/plain"
113
114 data_type = data_type.lower()
115
116 if data_type in self.data_types:
117 return self.data_types[data_type]
118 elif data_type in self.data_types.values():
119 return data_type
120 else:
121 raise TypeError(f"Invalid data type: {data_type}")
122
123 def _check_header(self, header: Union[Mapping[str, str], None] = None) -> Any:
124 """_summary_
125 Function in charge of checking the headers provided by the user.
126 Args:
127 header (Mapping[str, str], optional): _description_. Defaults to None.
128 Returns:
129 Any: _description_: Returns the correct known version of the sent headers.
130 """
131 if header is None:
132 return {}
133 elif isinstance(header, Dict):
134 return header
135 else:
136 msg = "Invalid header format, the format you provided is: "
137 msg += f"{type(header)}"
138 raise TypeError(msg)
139
140 def _process_data_content(self, data: Any, data_type: str) -> Any:
141 """_summary_
142 Function in charge of processing the data content to be sent.
143
144 Args:
145 data (Any): _description_: The data to be sent.
146 data_type (str): _description_: The type of the data to be sent.
147
148 Returns:
149 Any: _description_: The processed data.
150 """
151 if data is None:
152 return ""
153 if data_type == self.data_types['json'] and isinstance(data, Dict):
154 return json.dumps(data)
155 return str(data)
156
157 def send_message_on_status(self, status: int = 200, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
158 """
159 A generic function in charge of sending a message with a status.
160
161 Args:
162 status (int, optional): HTTP status code. Defaults to 200.
163 content (Any, optional): The content to send. Defaults to None.
164 content_type (str, optional): The type of the content. Defaults to "JSON".
165 headers (Mapping[str, str], optional): The headers. Defaults to None.
166
167 Returns:
168 Response: FastAPI response object.
169 """
170 data_type = self._check_data_type(content_type)
171 data_header = self._check_header(headers)
172 data = self._process_data_content(content, data_type)
173
174 if isinstance(status, str) and status.isnumeric():
175 status = int(status)
176
177 if status not in self.authorised_statuses:
178 raise ValueError(
179 f"Invalid status code, the code you entered is: {status}"
180 )
181
182 return Response(status_code=status, content=data, media_type=data_type, headers=data_header)
183
184 # """ 1xx informational response"""
185
186 def send_continue(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
187 """ send_continue: 100 """
188 return self.send_message_on_status(status=100, content=content, content_type=content_type, headers=headers)
189
190 def switching_protocols(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
191 """ switching_protocols: 101 """
192 return self.send_message_on_status(status=101, content=content, content_type=content_type, headers=headers)
193
194 def processing(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
195 """ processing: 102 """
196 return self.send_message_on_status(status=102, content=content, content_type=content_type, headers=headers)
197
198 def early_hints(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
199 """ early_hints: 103 """
200 return self.send_message_on_status(status=103, content=content, content_type=content_type, headers=headers)
201
202 def response_is_stale(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
203 """ response_is_stale: 110 """
204 return self.send_message_on_status(status=110, content=content, content_type=content_type, headers=headers)
205
206 # """success: 200"""
207
208 def success(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
209 """ success: 200 """
210 return self.send_message_on_status(status=200, content=content, content_type=content_type, headers=headers)
211
212 def created(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
213 """ created: 201 """
214 return self.send_message_on_status(status=201, content=content, content_type=content_type, headers=headers)
215
216 def accepted(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
217 """ accepted: 202 """
218 return self.send_message_on_status(status=202, content=content, content_type=content_type, headers=headers)
219
220 def non_authoritative_information(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
221 """ non_authoritative_information: 203 """
222 return self.send_message_on_status(status=203, content=content, content_type=content_type, headers=headers)
223
224 def no_content(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
225 """ no_content: 204 """
226 return self.send_message_on_status(status=204, content=content, content_type=content_type, headers=headers)
227
228 def reset_content(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
229 """ reset_content: 205 """
230 return self.send_message_on_status(status=205, content=content, content_type=content_type, headers=headers)
231
232 def partial_content(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
233 """ partial_content: 206 """
234 return self.send_message_on_status(status=206, content=content, content_type=content_type, headers=headers)
235
236 def multi_status(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
237 """ multi_status: 207 """
238 return self.send_message_on_status(status=207, content=content, content_type=content_type, headers=headers)
239
240 def already_reported(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
241 """ already_reported: 208 """
242 return self.send_message_on_status(status=208, content=content, content_type=content_type, headers=headers)
243
244 def im_used(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
245 """ im_used: 226 """
246 return self.send_message_on_status(status=226, content=content, content_type=content_type, headers=headers)
247
248 """ 3xx redirection """
249
250 def multiple_choices(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
251 """ multiple_choices: 300 """
252 return self.send_message_on_status(status=300, content=content, content_type=content_type, headers=headers)
253
254 def moved_permanently(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
255 """ moved_permanently: 301 """
256 return self.send_message_on_status(status=301, content=content, content_type=content_type, headers=headers)
257
258 def found(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
259 """ found: 302 """
260 return self.send_message_on_status(status=302, content=content, content_type=content_type, headers=headers)
261
262 def see_other(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
263 """ see_other: 303 """
264 return self.send_message_on_status(status=303, content=content, content_type=content_type, headers=headers)
265
266 def not_modified(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
267 """ not_modified: 304 """
268 return self.send_message_on_status(status=304, content=content, content_type=content_type, headers=headers)
269
270 def use_proxy(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
271 """ use_proxy: 305 """
272 return self.send_message_on_status(status=305, content=content, content_type=content_type, headers=headers)
273
274 def switch_proxy(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
275 """ switch_proxy: 306 """
276 return self.send_message_on_status(status=306, content=content, content_type=content_type, headers=headers)
277
278 def temporary_redirect(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
279 """ temporary_redirect: 307 """
280 return self.send_message_on_status(status=307, content=content, content_type=content_type, headers=headers)
281
282 def permanent_redirect(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
283 """ permanent_redirect: 308 """
284 return self.send_message_on_status(status=308, content=content, content_type=content_type, headers=headers)
285
286 """ 4xx client error """
287
288 def bad_request(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
289 """ bad_request: 400 """
290 return self.send_message_on_status(status=400, content=content, content_type=content_type, headers=headers)
291
292 def unauthorized(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
293 """ unauthorized: 401 """
294 return self.send_message_on_status(status=401, content=content, content_type=content_type, headers=headers)
295
296 def payment_required(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
297 """ payment_required: 402 """
298 return self.send_message_on_status(status=402, content=content, content_type=content_type, headers=headers)
299
300 def forbidden(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
301 """ forbidden: 403 """
302 return self.send_message_on_status(status=403, content=content, content_type=content_type, headers=headers)
303
304 def not_found(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
305 """ not_found: 404 """
306 return self.send_message_on_status(status=404, content=content, content_type=content_type, headers=headers)
307
308 def method_not_allowed(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
309 """ method_not_allowed: 405 """
310 return self.send_message_on_status(status=405, content=content, content_type=content_type, headers=headers)
311
312 def not_acceptable(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
313 """ not_acceptable: 406 """
314 return self.send_message_on_status(status=406, content=content, content_type=content_type, headers=headers)
315
316 def proxy_authentication_required(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
317 """ proxy_authentication_required: 407 """
318 return self.send_message_on_status(status=407, content=content, content_type=content_type, headers=headers)
319
320 def request_timeout(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
321 """ request_timeout: 408 """
322 return self.send_message_on_status(status=408, content=content, content_type=content_type, headers=headers)
323
324 def conflict(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
325 """ conflict: 409 """
326 return self.send_message_on_status(status=409, content=content, content_type=content_type, headers=headers)
327
328 def gone(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
329 """ gone: 410 """
330 return self.send_message_on_status(status=410, content=content, content_type=content_type, headers=headers)
331
332 def length_required(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
333 """ length_required: 411 """
334 return self.send_message_on_status(status=411, content=content, content_type=content_type, headers=headers)
335
336 def precondition_failed(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
337 """ precondition_failed: 412 """
338 return self.send_message_on_status(status=412, content=content, content_type=content_type, headers=headers)
339
340 def payload_too_large(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
341 """ payload_too_large: 413 """
342 return self.send_message_on_status(status=413, content=content, content_type=content_type, headers=headers)
343
344 def uri_too_long(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
345 """ uri_too_long: 414 """
346 return self.send_message_on_status(status=414, content=content, content_type=content_type, headers=headers)
347
348 def unsupported_media_type(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
349 """ unsupported_media_type: 415 """
350 return self.send_message_on_status(status=415, content=content, content_type=content_type, headers=headers)
351
352 def range_not_satisfiable(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
353 """ range_not_satisfiable: 416 """
354 return self.send_message_on_status(status=416, content=content, content_type=content_type, headers=headers)
355
356 def expectation_failed(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
357 """ expectation_failed: 417 """
358 return self.send_message_on_status(status=417, content=content, content_type=content_type, headers=headers)
359
360 def im_a_teapot(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
361 """ im_a_teapot: 418 """
362 return self.send_message_on_status(status=418, content=content, content_type=content_type, headers=headers)
363
364 def page_expired(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
365 """ page_expired: 419 """
366 return self.send_message_on_status(status=419, content=content, content_type=content_type, headers=headers)
367
368 def enhance_your_calm(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
369 """ enhance_your_calm: 420 """
370 return self.send_message_on_status(status=420, content=content, content_type=content_type, headers=headers)
371
372 def misdirected_request(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
373 """ misdirected_request: 421 """
374 return self.send_message_on_status(status=421, content=content, content_type=content_type, headers=headers)
375
376 def unprocessable_entity(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
377 """ unprocessable_entity: 422 """
378 return self.send_message_on_status(status=422, content=content, content_type=content_type, headers=headers)
379
380 def locked(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
381 """ locked: 423 """
382 return self.send_message_on_status(status=423, content=content, content_type=content_type, headers=headers)
383
384 def failed_dependency(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
385 """ failed_dependency: 424 """
386 return self.send_message_on_status(status=424, content=content, content_type=content_type, headers=headers)
387
388 def too_early(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
389 """ too_early: 425 """
390 return self.send_message_on_status(status=425, content=content, content_type=content_type, headers=headers)
391
392 def upgrade_required(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
393 """ upgrade_required: 426 """
394 return self.send_message_on_status(status=426, content=content, content_type=content_type, headers=headers)
395
396 def precondition_required(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
397 """ precondition_required: 428 """
398 return self.send_message_on_status(status=428, content=content, content_type=content_type, headers=headers)
399
400 def too_many_requests(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
401 """ too_many_requests: 429 """
402 return self.send_message_on_status(status=429, content=content, content_type=content_type, headers=headers)
403
404 def request_header_fields_too_large(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
405 """ request_header_fields_too_large: 431 """
406 return self.send_message_on_status(status=431, content=content, content_type=content_type, headers=headers)
407
408 def unavailable_for_legal_reasons(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
409 """ unavailable_for_legal_reasons: 451 """
410 return self.send_message_on_status(status=451, content=content, content_type=content_type, headers=headers)
411
412 def invalid_token(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
413 """ invalid_token: 498 """
414 return self.send_message_on_status(status=498, content=content, content_type=content_type, headers=headers)
415
416 """ 5xx server error"""
417
418 def internal_server_error(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
419 """ internal_server_error: 500 """
420 return self.send_message_on_status(status=500, content=content, content_type=content_type, headers=headers)
421
422 def not_implemented(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
423 """ not_implemented: 501 """
424 return self.send_message_on_status(status=501, content=content, content_type=content_type, headers=headers)
425
426 def bad_gateway(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
427 """ bad_gateway: 502 """
428 return self.send_message_on_status(status=502, content=content, content_type=content_type, headers=headers)
429
430 def service_unavailable(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
431 """ service_unavailable: 503 """
432 return self.send_message_on_status(status=503, content=content, content_type=content_type, headers=headers)
433
434 def gateway_timeout(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
435 """ gateway_timeout: 504 """
436 return self.send_message_on_status(status=504, content=content, content_type=content_type, headers=headers)
437
438 def http_version_not_supported(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
439 """ http_version_not_supported: 505 """
440 return self.send_message_on_status(status=505, content=content, content_type=content_type, headers=headers)
441
442 def variant_also_negotiates(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
443 """ variant_also_negotiates: 506 """
444 return self.send_message_on_status(status=506, content=content, content_type=content_type, headers=headers)
445
446 def insufficient_storage(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
447 """ insufficient_storage: 507 """
448 return self.send_message_on_status(status=507, content=content, content_type=content_type, headers=headers)
449
450 def loop_detected(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
451 """ loop_detected: 508 """
452 return self.send_message_on_status(status=508, content=content, content_type=content_type, headers=headers)
453
454 def bandwidth_limit_exceeded(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
455 """ bandwidth_limit_exceeded: 509 """
456 return self.send_message_on_status(status=509, content=content, content_type=content_type, headers=headers)
457
458 def not_extended(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
459 """ not_extended: 510 """
460 return self.send_message_on_status(status=510, content=content, content_type=content_type, headers=headers)
461
462 def network_authentication_required(self, content: Any = {'msg': 'message'}, content_type: str = "JSON", headers: Mapping[str, str] = None) -> Response:
463 """ network_authentication_required: 511 """
464 return self.send_message_on_status(status=511, content=content, content_type=content_type, headers=headers)
465
466
467HCI = HttpCodes()
Response request_timeout(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response uri_too_long(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response invalid_token(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response found(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response switching_protocols(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response proxy_authentication_required(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Any _process_data_content(self, Any data, str data_type)
Response switch_proxy(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response conflict(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response send_continue(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response send_message_on_status(self, int status=200, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response payment_required(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response unauthorized(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response multiple_choices(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response precondition_failed(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response reset_content(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response response_is_stale(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response too_many_requests(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response created(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response temporary_redirect(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response gone(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response length_required(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response partial_content(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response enhance_your_calm(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response im_used(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response moved_permanently(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response expectation_failed(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response unsupported_media_type(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response misdirected_request(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response request_header_fields_too_large(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response bad_request(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response forbidden(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response locked(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response not_modified(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response accepted(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response failed_dependency(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response unavailable_for_legal_reasons(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Any _check_header(self, Union[Mapping[str, str], None] header=None)
Response precondition_required(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response too_early(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response page_expired(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response already_reported(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response no_content(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response permanent_redirect(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response multi_status(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response use_proxy(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response early_hints(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response method_not_allowed(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response range_not_satisfiable(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response processing(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response see_other(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response unprocessable_entity(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response not_found(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response non_authoritative_information(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
str _check_data_type(self, Union[str, None] data_type=None)
Response im_a_teapot(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response payload_too_large(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response success(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response upgrade_required(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)
Response not_acceptable(self, Any content={ 'msg':'message'}, str content_type="JSON", Mapping[str, str] headers=None)