File Coverage

lib/HTTP/Promise/Status.pm
Criterion Covered Total %
statement 58 66 87.8
branch 6 14 42.8
condition 10 12 83.3
subroutine 22 24 91.6
pod 11 13 84.6
total 107 129 82.9


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Asynchronous HTTP Request and Promise - ~/lib/HTTP/Promise/Status.pm
3             ## Version v0.1.0
4             ## Copyright(c) 2022 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2022/04/05
7             ## Modified 2022/04/05
8             ## All rights reserved
9             ##
10             ## This program is free software; you can redistribute it and/or modify it
11             ## under the same terms as Perl itself.
12             ##----------------------------------------------------------------------------
13             package HTTP::Promise::Status;
14             BEGIN
15             {
16 5     5   225170 use strict;
  5         20  
  5         153  
17 5     5   30 use warnings;
  5         7  
  5         146  
18 5     5   35 use parent qw( Module::Generic );
  5         8  
  5         32  
19 5         1105 use vars qw( $VERSION @EXPORT @EXPORT_OK %EXPORT_TAGS
20 5     5   97926 $CODES_LOCALE $CODES_LANG_SHORT );
  5         15  
21 5     5   22 our $VERSION = 'v0.1.0';
22             use constant
23             {
24 5         4043 HTTP_CONTINUE => 100,
25             HTTP_SWITCHING_PROTOCOLS => 101,
26             HTTP_PROCESSING => 102,
27             HTTP_EARLY_HINTS => 103,
28             HTTP_OK => 200,
29             HTTP_CREATED => 201,
30             HTTP_ACCEPTED => 202,
31             HTTP_NON_AUTHORITATIVE => 203,
32             HTTP_NO_CONTENT => 204,
33             HTTP_RESET_CONTENT => 205,
34             HTTP_PARTIAL_CONTENT => 206,
35             HTTP_MULTI_STATUS => 207,
36             HTTP_ALREADY_REPORTED => 208,
37             HTTP_IM_USED => 226,
38             HTTP_MULTIPLE_CHOICES => 300,
39             HTTP_MOVED_PERMANENTLY => 301,
40             HTTP_MOVED_TEMPORARILY => 302,
41             HTTP_SEE_OTHER => 303,
42             HTTP_NOT_MODIFIED => 304,
43             HTTP_USE_PROXY => 305,
44             HTTP_TEMPORARY_REDIRECT => 307,
45             HTTP_PERMANENT_REDIRECT => 308,
46             HTTP_BAD_REQUEST => 400,
47             HTTP_UNAUTHORIZED => 401,
48             HTTP_PAYMENT_REQUIRED => 402,
49             HTTP_FORBIDDEN => 403,
50             HTTP_NOT_FOUND => 404,
51             HTTP_METHOD_NOT_ALLOWED => 405,
52             HTTP_NOT_ACCEPTABLE => 406,
53             HTTP_PROXY_AUTHENTICATION_REQUIRED => 407,
54             HTTP_REQUEST_TIME_OUT => 408,
55             HTTP_CONFLICT => 409,
56             HTTP_GONE => 410,
57             HTTP_LENGTH_REQUIRED => 411,
58             HTTP_PRECONDITION_FAILED => 412,
59             HTTP_REQUEST_ENTITY_TOO_LARGE => 413,
60             # Compatibility with HTTP::Status
61             HTTP_PAYLOAD_TOO_LARGE => 413,
62             HTTP_REQUEST_URI_TOO_LARGE => 414,
63             HTTP_URI_TOO_LONG => 414,
64             HTTP_UNSUPPORTED_MEDIA_TYPE => 415,
65             HTTP_RANGE_NOT_SATISFIABLE => 416,
66             # Compatibility with HTTP::Status
67             HTTP_REQUEST_RANGE_NOT_SATISFIABLE => 416,
68             HTTP_EXPECTATION_FAILED => 417,
69             HTTP_I_AM_A_TEA_POT => 418,
70             # Compatibility with HTTP::Status
71             HTTP_I_AM_A_TEAPOT => 418,
72             HTTP_MISDIRECTED_REQUEST => 421,
73             HTTP_UNPROCESSABLE_ENTITY => 422,
74             HTTP_LOCKED => 423,
75             HTTP_FAILED_DEPENDENCY => 424,
76             HTTP_TOO_EARLY => 425,
77             # Compatibility with HTTP::Status
78             HTTP_NO_CODE => 425,
79             # Compatibility with HTTP::Status
80             HTTP_UNORDERED_COLLECTION => 425,
81             HTTP_UPGRADE_REQUIRED => 426,
82             HTTP_PRECONDITION_REQUIRED => 428,
83             HTTP_TOO_MANY_REQUESTS => 429,
84             HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE => 431,
85             HTTP_CONNECTION_CLOSED_WITHOUT_RESPONSE => 444,
86             HTTP_UNAVAILABLE_FOR_LEGAL_REASONS => 451,
87             HTTP_CLIENT_CLOSED_REQUEST => 499,
88             HTTP_INTERNAL_SERVER_ERROR => 500,
89             HTTP_NOT_IMPLEMENTED => 501,
90             HTTP_BAD_GATEWAY => 502,
91             HTTP_SERVICE_UNAVAILABLE => 503,
92             HTTP_GATEWAY_TIME_OUT => 504,
93             HTTP_VERSION_NOT_SUPPORTED => 505,
94             HTTP_VARIANT_ALSO_VARIES => 506,
95             HTTP_INSUFFICIENT_STORAGE => 507,
96             HTTP_LOOP_DETECTED => 508,
97             HTTP_BANDWIDTH_LIMIT_EXCEEDED => 509,
98             HTTP_NOT_EXTENDED => 510,
99             HTTP_NETWORK_AUTHENTICATION_REQUIRED => 511,
100             HTTP_NETWORK_CONNECT_TIMEOUT_ERROR => 599,
101 5     5   39 };
  5         13  
102 5         70 our @EXPORT_OK = qw(
103             HTTP_ACCEPTED HTTP_ALREADY_REPORTED HTTP_BAD_GATEWAY HTTP_BAD_REQUEST
104             HTTP_BANDWIDTH_LIMIT_EXCEEDED HTTP_CLIENT_CLOSED_REQUEST HTTP_CONFLICT
105             HTTP_CONNECTION_CLOSED_WITHOUT_RESPONSE HTTP_CONTINUE HTTP_CREATED
106             HTTP_EARLY_HINTS HTTP_EXPECTATION_FAILED HTTP_FAILED_DEPENDENCY
107             HTTP_FORBIDDEN HTTP_GATEWAY_TIME_OUT HTTP_GONE HTTP_IM_USED
108             HTTP_INSUFFICIENT_STORAGE HTTP_INTERNAL_SERVER_ERROR
109             HTTP_I_AM_A_TEAPOT HTTP_I_AM_A_TEA_POT HTTP_LENGTH_REQUIRED
110             HTTP_LOCKED HTTP_LOOP_DETECTED HTTP_METHOD_NOT_ALLOWED
111             HTTP_MISDIRECTED_REQUEST HTTP_MOVED_PERMANENTLY HTTP_MOVED_TEMPORARILY
112             HTTP_MULTIPLE_CHOICES HTTP_MULTI_STATUS
113             HTTP_NETWORK_AUTHENTICATION_REQUIRED
114             HTTP_NETWORK_CONNECT_TIMEOUT_ERROR HTTP_NON_AUTHORITATIVE
115             HTTP_NOT_ACCEPTABLE HTTP_NOT_EXTENDED HTTP_NOT_FOUND
116             HTTP_NOT_IMPLEMENTED HTTP_NOT_MODIFIED HTTP_NO_CODE HTTP_NO_CONTENT
117             HTTP_OK HTTP_PARTIAL_CONTENT HTTP_PAYLOAD_TOO_LARGE
118             HTTP_PAYMENT_REQUIRED HTTP_PERMANENT_REDIRECT HTTP_PRECONDITION_FAILED
119             HTTP_PRECONDITION_REQUIRED HTTP_PROCESSING
120             HTTP_PROXY_AUTHENTICATION_REQUIRED HTTP_RANGE_NOT_SATISFIABLE
121             HTTP_REQUEST_ENTITY_TOO_LARGE HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE
122             HTTP_REQUEST_RANGE_NOT_SATISFIABLE HTTP_REQUEST_TIME_OUT
123             HTTP_REQUEST_URI_TOO_LARGE HTTP_RESET_CONTENT HTTP_SEE_OTHER
124             HTTP_SERVICE_UNAVAILABLE HTTP_SWITCHING_PROTOCOLS
125             HTTP_TEMPORARY_REDIRECT HTTP_TOO_EARLY HTTP_TOO_MANY_REQUESTS
126             HTTP_UNAUTHORIZED HTTP_UNAVAILABLE_FOR_LEGAL_REASONS
127             HTTP_UNORDERED_COLLECTION HTTP_UNPROCESSABLE_ENTITY
128             HTTP_UNSUPPORTED_MEDIA_TYPE HTTP_UPGRADE_REQUIRED HTTP_URI_TOO_LONG
129             HTTP_USE_PROXY HTTP_VARIANT_ALSO_VARIES HTTP_VERSION_NOT_SUPPORTED
130             );
131 5         581 our %EXPORT_TAGS = (
132             all => [@EXPORT_OK],
133             common => [qw( HTTP_NETWORK_AUTHENTICATION_REQUIRED HTTP_FORBIDDEN HTTP_NOT_FOUND HTTP_OK HTTP_TEMPORARY_REDIRECT HTTP_INTERNAL_SERVER_ERROR )],
134             );
135             };
136              
137             sub import
138             {
139 10     10   7268 my $class = shift( @_ );
140 10         29 local $Exporter::ExportLevel = 1;
141 10         2408 Exporter::import( $class, @_ );
142             }
143              
144             {
145 5     5   57 use utf8;
  5         16  
  5         99  
146             our $CODES_LOCALE =
147             {
148             # Ref: <https://developer.mozilla.org/de/docs/Web/HTTP/Status/100>
149             # <https://www.dotcom-monitor.com/wiki/de/knowledge-base/http-status-codes/>
150             'de_DE' =>
151             {
152             100 => "Weiter",
153             101 => "Protokolle wechseln",
154             102 => "Verarbeitung",
155             103 => "Frühe Hinweise",
156             200 => "OK",
157             201 => "Erstellt",
158             202 => "Akzeptiert",
159             203 => "Nicht autorisierende Informationen",
160             204 => "Kein Inhalt",
161             205 => "Inhalt zurücksetzen",
162             206 => "Teilinhalt",
163             207 => "Multi-Status",
164             208 => "Bereits gemeldet",
165             226 => "IM verwendet",
166             300 => "Mehrfachauswahlmöglichkeiten",
167             301 => "Dauerhaft verschoben",
168             302 => "Gefunden",
169             303 => "Andere sehen",
170             304 => "Nicht geändert",
171             305 => "Proxy verwenden",
172             307 => "Temporäre Weiterleitung",
173             308 => "Permanente Weiterleitung",
174             400 => "Schlechte Anfrage",
175             401 => "Nicht autorisiert",
176             402 => "Zahlung erforderlich",
177             403 => "Verboten",
178             404 => "Nicht gefunden",
179             405 => "Methode nicht erlaubt",
180             406 => "Nicht akzeptabel",
181             407 => "Proxy-Authentifizierung erforderlich",
182             408 => "Anfrage timeout",
183             409 => "Konflikt",
184             410 => "Gegangen",
185             411 => "Länge erforderlich",
186             412 => "Vorbedingung fehlgeschlagen",
187             413 => "Nutzlast zu groß",
188             414 => "Anfrage-URI zu lang",
189             415 => "Nicht unterstützter Medientyp",
190             416 => "Reichweite nicht erfüllbar",
191             417 => "Erwartung fehlgeschlagen",
192             418 => "Ich bin eine Teekanne",
193             421 => "Fehlgeleitete Anfrage",
194             422 => "Nicht verarbeitbare Entität",
195             423 => "Gesperrt",
196             424 => "Fehlgeschlagene Abhängigkeit",
197             425 => "Zu früh",
198             426 => "Upgrade erforderlich",
199             428 => "Vorbedingung erforderlich",
200             429 => "Zu viele Anfragen",
201             431 => "Headerfelder zu groß anfordern",
202             444 => "Verbindung ohne Antwort geschlossen",
203             451 => "Aus rechtlichen Gründen nicht verfügbar",
204             499 => "Client die Verbindung schließt",
205             500 => "Interner Serverfehler",
206             501 => "Nicht implementiert",
207             502 => "Schlechtes Gateway",
208             503 => "Dienst nicht verfügbar",
209             504 => "Gateway-Zeitüberschreitung",
210             505 => "HTTP-Version nicht unterstützt",
211             506 => "Variante verhandelt auch",
212             507 => "Unzureichende Lagerung",
213             508 => "Schleife erkannt",
214             509 => "Bandbreitenlimit überschritten",
215             510 => "Nicht erweitert",
216             511 => "Netzwerkauthentifizierung erforderlich",
217             599 => "Timeout-Fehler bei Netzwerkverbindung",
218             },
219             'en_GB' =>
220             {
221             100 => "Continue",
222             101 => "Switching Protocols",
223             102 => "Processing",
224             103 => "Early Hints",
225             200 => "OK",
226             201 => "Created",
227             202 => "Accepted",
228             203 => "Non-authoritative Information",
229             204 => "No Content",
230             205 => "Reset Content",
231             206 => "Partial Content",
232             207 => "Multi-Status",
233             208 => "Already Reported",
234             226 => "IM Used",
235             300 => "Multiple Choices",
236             301 => "Moved Permanently",
237             302 => "Found",
238             303 => "See Other",
239             304 => "Not Modified",
240             305 => "Use Proxy",
241             307 => "Temporary Redirect",
242             308 => "Permanent Redirect",
243             400 => "Bad Request",
244             401 => "Unauthorized",
245             402 => "Payment Required",
246             403 => "Forbidden",
247             404 => "Not Found",
248             405 => "Method Not Allowed",
249             406 => "Not Acceptable",
250             407 => "Proxy Authentication Required",
251             408 => "Request Timeout",
252             409 => "Conflict",
253             410 => "Gone",
254             411 => "Length Required",
255             412 => "Precondition Failed",
256             413 => "Payload Too Large",
257             414 => "Request-URI Too Long",
258             415 => "Unsupported Media Type",
259             416 => "Requested Range Not Satisfiable",
260             417 => "Expectation Failed",
261             # Humour: April's fool
262             # <https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol>
263             418 => "I'm a teapot",
264             421 => "Misdirected Request",
265             422 => "Unprocessable Entity",
266             423 => "Locked",
267             424 => "Failed Dependency",
268             425 => "Too Early",
269             426 => "Upgrade Required",
270             428 => "Precondition Required",
271             429 => "Too Many Requests",
272             431 => "Request Header Fields Too Large",
273             444 => "Connection Closed Without Response",
274             451 => "Unavailable For Legal Reasons",
275             499 => "Client Closed Request",
276             500 => "Internal Server Error",
277             501 => "Not Implemented",
278             502 => "Bad Gateway",
279             503 => "Service Unavailable",
280             504 => "Gateway Timeout",
281             505 => "HTTP Version Not Supported",
282             506 => "Variant Also Negotiates",
283             507 => "Insufficient Storage",
284             508 => "Loop Detected",
285             509 => "Bandwidth Limit Exceeded",
286             510 => "Not Extended",
287             511 => "Network Authentication Required",
288             599 => "Network Connect Timeout Error",
289             },
290             'fr_FR' =>
291             {
292             100 => "Continuer",
293             101 => "Changement de protocole",
294             102 => "En traitement",
295             103 => "Premiers indices",
296             200 => "OK",
297             201 => "Créé",
298             202 => "Accepté",
299             203 => "Information non certifiée",
300             204 => "Pas de contenu",
301             205 => "Contenu réinitialisé",
302             206 => "Contenu partiel",
303             207 => "Multi-Status",
304             208 => "Déjà rapporté",
305             226 => "IM Used",
306             300 => "Choix multiples",
307             301 => "Changement d'adresse définitif",
308             302 => "Changement d'adresse temporaire",
309             303 => "Voir ailleurs",
310             304 => "Non modifié",
311             305 => "Utiliser le proxy",
312             307 => "Redirection temporaire",
313             308 => "Redirection permanente",
314             400 => "Mauvaise requête",
315             401 => "Non autorisé",
316             402 => "Paiement exigé",
317             403 => "Interdit",
318             404 => "Non trouvé",
319             405 => "Méthode non autorisée",
320             406 => "Pas acceptable",
321             407 => "Authentification proxy exigée",
322             408 => "Requête hors-délai",
323             409 => "Conflit",
324             410 => "Parti",
325             411 => "Longueur exigée",
326             412 => "Précondition échouée",
327             413 => "Corps de requête trop grand",
328             414 => "URI trop long",
329             415 => "Format non supporté",
330             416 => "Plage demandée invalide",
331             417 => "Comportement erroné",
332             # Humour; poisson d'avril
333             # <https://fr.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol>
334             418 => "Je suis une théière",
335             421 => "Requête mal dirigée",
336             422 => "Entité intraitable",
337             423 => "Vérouillé",
338             424 => "Dépendence échouée",
339             425 => "Trop tôt",
340             426 => "Mis-à-jour requise",
341             428 => "Précondition requise",
342             429 => "Trop de requête",
343             431 => "Champs d'entête de la requête trop large",
344             444 => "Connexion clôturée sans réponse",
345             451 => "Indisponible pour des raisons légales",
346             499 => "Le client a terminé la requête",
347             500 => "Erreur interne du serveur",
348             501 => "Non implémenté",
349             502 => "Mauvais intermédiaire",
350             503 => "Service indisponible",
351             504 => "Intermédiaire hors-délai",
352             505 => "Version HTTP non supportée",
353             506 => "Variant Also Negotiates",
354             507 => "Stoquage insuffisant",
355             508 => "Boucle detectée",
356             509 => "Limite de bande passante dépassée",
357             510 => "Pas étendu",
358             511 => "Autentification réseau requise",
359             599 => "Erreur de timeout connexion réseau",
360             },
361             'ja_JP' =>
362             {
363             100 => "継続",
364             101 => "プロトコル切替",
365             102 => "処理中",
366             103 => "早期のヒント",
367             200 => "成功",
368             201 => "作成完了",
369             202 => "受理",
370             203 => "信頼できない情報",
371             204 => "内容なし",
372             205 => "内容をリセット",
373             206 => "部分的内容",
374             207 => "複数のステータス",
375             208 => "既に報告",
376             226 => "IM使用",
377             300 => "複数の選択",
378             301 => "恒久的に移動した",
379             302 => "発見した",
380             303 => "他を参照せよ",
381             304 => "未更新",
382             305 => "プロキシを使用せよ",
383             307 => "一時的リダイレクト",
384             308 => "恒久的リダイレクト",
385             400 => "リクエストが不正である",
386             401 => "認証が必要である",
387             402 => "支払いが必要である",
388             403 => "禁止されている",
389             404 => "未検出",
390             405 => "許可されていないメソッド",
391             406 => "受理できない",
392             407 => "プロキシ認証が必要である",
393             408 => "リクエストタイムアウト",
394             409 => "競合",
395             410 => "消滅した",
396             411 => "長さが必要",
397             412 => "前提条件で失敗した",
398             413 => "ペイロードが大きすぎる",
399             414 => "URIが大きすぎる",
400             415 => "サポートしていないメディアタイプ",
401             416 => "レンジは範囲外にある",
402             417 => "Expectヘッダによる拡張が失敗",
403             418 => "私はティーポット",
404             421 => "誤ったリクエスト",
405             422 => "処理できないエンティティ",
406             423 => "ロックされている",
407             424 => "依存関係で失敗",
408             425 => "早期すぎ",
409             426 => "アップグレード要求",
410             428 => "条件付きリクエストを要求",
411             429 => "リクエスト過大で拒否した",
412             431 => "ヘッダサイズが過大",
413             444 => "応答なしで接続が閉じられました",
414             451 => "法的理由により利用不可",
415             499 => "クライアントによるリクエストの終了",
416             500 => "サーバ内部エラー",
417             501 => "実装されていない",
418             502 => "不正なゲートウェイ",
419             503 => "サービス利用不可",
420             504 => "ゲートウェイタイムアウト",
421             505 => "サポートしていないHTTPバージョン",
422             506 => "バリアントもコンテンツネゴシエーションを行う",
423             507 => "容量不足",
424             508 => "ループを検出",
425             509 => "帯域幅制限超過",
426             510 => "拡張できない",
427             511 => "ネットワーク認証が必要",
428             599 => "ネットワーク接続タイムアウトエラー",
429             },
430             # Ref: <https://developer.mozilla.org/ko/docs/Web/HTTP/Status>
431             # <https://ko.wikipedia.org/wiki/HTTP_%EC%83%81%ED%83%9C_%EC%BD%94%EB%93%9C>
432             # <http://wiki.hash.kr/index.php/HTTP>
433             'ko_KR'=>
434             {
435             100 => "계속",
436             101 => "스위칭 프로토콜",
437             102 => "처리 중",
438             103 => "사전로딩",
439             200 => "확인",
440             201 => "만든",
441             202 => "수락",
442             203 => "비 권한 정보",
443             204 => "내용 없음",
444             205 => "콘텐츠 재설정",
445             206 => "부분적인 내용",
446             207 => "다중 상태",
447             208 => "이미보고",
448             226 => "IM 사용",
449             300 => "다중 선택",
450             301 => "영구 이동",
451             302 => "발견",
452             303 => "다른 참조",
453             304 => "수정되지 않음",
454             305 => "프록시 사용",
455             307 => "임시 리디렉션",
456             308 => "영구 리디렉션",
457             400 => "잘못된 요청",
458             401 => "권한 없음",
459             402 => "결제 필요",
460             403 => "금지됨",
461             404 => "찾을 수 없음",
462             405 => "허용되지 않는 방법",
463             406 => "허용되지 않음",
464             407 => "프록시 인증 필요",
465             408 => "요청 시간초과",
466             409 => "충돌",
467             410 => "사라짐",
468             411 => "길이 필요",
469             412 => "사전조건 실패",
470             413 => "요청 속성이 너무 큼",
471             414 => "요청 URI가 너무 긺",
472             415 => "지원되지 않는 미디어 유형",
473             416 => "처리할 수 없는 요청범위",
474             417 => "예상 실패",
475             418 => "나는 주전자입니다",
476             421 => "잘못된 요청",
477             422 => "처리할 수 없는 엔티티",
478             423 => "잠김",
479             424 => "실패된 의존성",
480             425 => "너무일찍요청",
481             426 => "업그레이드 필요",
482             428 => "전제조건 필요",
483             429 => "너무 많은 요청",
484             431 => "요청 헤더 필드가 너무 큼",
485             444 => "응답없이 연결이 닫힘",
486             451 => "법적인 이유로 이용 불가",
487             499 => "요청 헤더가 너무 큼",
488             500 => "내부 서버 오류",
489             501 => "구현되지 않음",
490             502 => "불량 게이트웨이",
491             503 => "서비스를 사용할 수 없음",
492             504 => "게이트웨이 시간초과",
493             505 => "HTTP 버전이 지원되지 않음",
494             ## This is left in English by design
495             506 => "Variant Also Negotiates",
496             507 => "용량 부족",
497             508 => "루프 감지됨",
498             509 => "대역폭 제한 초과",
499             510 => "확장되지 않음",
500             511 => "네트워크 인증 필요",
501             599 => "네트워크 연결 시간초과 오류",
502             },
503             # Ref: <https://ru.wikipedia.org/wiki/%D0%A1%D0%BF%D0%B8%D1%81%D0%BE%D0%BA_%D0%BA%D0%BE%D0%B4%D0%BE%D0%B2_%D1%81%D0%BE%D1%81%D1%82%D0%BE%D1%8F%D0%BD%D0%B8%D1%8F_HTTP>
504             # <https://developer.roman.grinyov.name/blog/80>
505             'ru_RU' =>
506             {
507             100 => "продолжай",
508             101 => "переключение протоколов",
509             102 => "идёт обработка",
510             103 => "ранняя метаинформация",
511             200 => "хорошо",
512             201 => "создано",
513             202 => "принято",
514             203 => "информация не авторитетна",
515             204 => "нет содержимого",
516             205 => "сбросить содержимое",
517             206 => "частичное содержимое",
518             207 => "многостатусный",
519             208 => "уже сообщалось",
520             226 => "использовано IM",
521             300 => "множество выборов",
522             301 => "перемещено навсегда",
523             302 => "найдено",
524             303 => "смотреть другое",
525             304 => "не изменялось",
526             305 => "использовать прокси",
527             307 => "временное перенаправление",
528             308 => "постоянное перенаправление",
529             400 => "неправильный запрос",
530             401 => "не авторизован",
531             402 => "необходима оплата",
532             403 => "запрещено",
533             404 => "не найдено",
534             405 => "метод не поддерживается",
535             406 => "неприемлемо",
536             407 => "необходима аутентификация прокси",
537             408 => "истекло время ожидания",
538             409 => "конфликт",
539             410 => "удалён",
540             411 => "необходима длина",
541             412 => "условие ложно",
542             413 => "полезная нагрузка слишком велика",
543             414 => "URI слишком длинный",
544             415 => "неподдерживаемый тип данных",
545             416 => "диапазон не достижим",
546             417 => "ожидание не удалось",
547             418 => "я — чайник",
548             421 => "Неверно адресованный запрос",
549             422 => "необрабатываемый экземпляр",
550             423 => "заблокировано",
551             424 => "невыполненная зависимость",
552             425 => "слишком рано",
553             426 => "необходимо обновление",
554             428 => "необходимо предусловие",
555             429 => "слишком много запросов",
556             431 => "поля заголовка запроса слишком большие",
557             444 => "Соединение закрыто без ответа",
558             451 => "недоступно по юридическим причинам",
559             499 => "клиент закрыл соединение",
560             500 => "внутренняя ошибка сервера",
561             501 => "не реализовано",
562             502 => "ошибочный шлюз",
563             503 => "сервис недоступен",
564             504 => "шлюз не отвечает",
565             505 => "версия HTTP не поддерживается",
566             506 => "вариант тоже проводит согласование",
567             507 => "переполнение хранилища",
568             508 => "обнаружено бесконечное перенаправление",
569             509 => "исчерпана пропускная ширина канала",
570             510 => "не расширено",
571             511 => "требуется сетевая аутентификация",
572             599 => "Ошибка тайм-аута сетевого подключения",
573             },
574             # Ref: <https://zh.wikipedia.org/zh-tw/HTTP%E7%8A%B6%E6%80%81%E7%A0%81>
575             # <https://developer.mozilla.org/zh-TW/docs/Web/HTTP/Status>
576             # <https://www.websitehostingrating.com/zh-TW/http-status-codes-cheat-sheet/>
577             'zh_TW' =>
578             {
579             100 => "繼續",
580             101 => "交換協議",
581             102 => "處理",
582             103 => "早期提示",
583             200 => "OK",
584             201 => "已創建",
585             202 => "已收到請求",
586             203 => "非權威信息",
587             204 => "沒有內容",
588             205 => "重設內容",
589             206 => "部分內容",
590             207 => "種多狀態",
591             208 => "已報告",
592             226 => "使用了IM",
593             300 => "種選擇",
594             301 => "永久移動",
595             302 => "找到了",
596             303 => "查看其他",
597             304 => "未修改",
598             305 => "使用代理",
599             307 => "臨時重定向",
600             308 => "永久重定向",
601             400 => "錯誤的請求",
602             401 => "未經授權",
603             402 => "需要付款",
604             403 => "故宮",
605             404 => "未找到",
606             405 => "方法不允許",
607             406 => "不可接受",
608             407 => "要求代理身份驗證",
609             408 => "請求超時",
610             409 => "衝突",
611             410 => "已經過時了",
612             411 => "長度必需",
613             412 => "前提條件失敗",
614             413 => "有效負載過大",
615             414 => "請求URI太長",
616             415 => "不支持的媒體類型",
617             416 => "請求的範圍不滿足",
618             417 => "期望失敗",
619             418 => "我是茶壺",
620             421 => "錯誤的請求",
621             422 => "無法處理的實體",
622             423 => "已鎖定",
623             424 => "依賴失敗",
624             425 => "太早了",
625             426 => "需要升級",
626             428 => "需要先決條件",
627             429 => "請求太多",
628             431 => "請求標頭字段太大",
629             444 => "連接關閉而沒有響應",
630             451 => "由於法律原因不可用",
631             499 => "個客戶關閉的請求",
632             500 => "內部服務器錯誤",
633             501 => "未實施",
634             502 => "錯誤的網關",
635             503 => "服務不可用",
636             504 => "網關超時",
637             505 => "不支持HTTP版本",
638             506 => "變種還可以協商",
639             507 => "存儲空間不足",
640             508 => "檢測到環路",
641             509 => "超過帶寬限制",
642             510 => "未擴展",
643             511 => "要求網絡身份驗證",
644             599 => "網絡連接超時錯誤",
645             },
646             };
647             our $CODES_LANG_SHORT =
648             {
649             de => 'de_DE',
650             en => 'en_GB',
651             fr => 'fr_FR',
652             ja => 'ja_JP',
653             ko => 'ko_KR',
654             ru => 'ru_RU',
655             zh => 'zh_TW',
656             };
657             }
658              
659 5     5   10679 use strict;
  5         14  
  5         138  
660 5     5   27 use warnings;
  5         23  
  5         4099  
661              
662             sub init
663             {
664 2     2 1 868 my $self = shift( @_ );
665 2         156 $self->{_init_strict_use_sub} = 1;
666 2 50       35 $self->SUPER::init( @_ ) || return( $self->pass_error );
667 2         215 return( $self );
668             }
669              
670             sub convert_short_lang_to_long
671             {
672 0     0 1 0 my $self = shift( @_ );
673 0         0 my $lang = shift( @_ );
674             # Nothing to do; we already have a good value
675 0 0       0 return( $lang ) if( $lang =~ /^[a-z]{2}_[A-Z]{2}$/ );
676 0 0       0 return( $CODES_LANG_SHORT->{ lc( $lang ) } ) if( CORE::exists( $CODES_LANG_SHORT->{ lc( $lang ) } ) );
677 0         0 return( '' );
678             }
679              
680             sub is_cacheable_by_default
681             {
682 18     18 1 6872 my $self = shift( @_ );
683 18         32 my $code = shift( @_ );
684 18 50 33     119 return( $self->error( "A 3 digit code is required." ) ) if( !defined( $code ) || $code !~ /^\d{3}$/ );
685             return(
686 18   100     268 $code == 200 # OK
687             || $code == 203 # Non-Authoritative Information
688             || $code == 204 # No Content
689             || $code == 206 # Not Acceptable
690             || $code == 300 # Multiple Choices
691             || $code == 301 # Moved Permanently
692             || $code == 308 # Permanent Redirect
693             || $code == 404 # Not Found
694             || $code == 405 # Method Not Allowed
695             || $code == 410 # Gone
696             || $code == 414 # Request-URI Too Large
697             || $code == 451 # Unavailable For Legal Reasons
698             || $code == 501 # Not Implemented
699             );
700             }
701              
702 3     3 1 359 sub is_client_error { return( shift->_min_max( 400 => 500, @_ ) ); }
703              
704 12     12 1 374 sub is_error { return( shift->_min_max( 400 => 600, @_ ) ); }
705              
706 4     4 1 69362 sub is_info { return( shift->_min_max( 100 => 200, @_ ) ); }
707              
708 5     5 1 3113 sub is_redirect { return( shift->_min_max( 300 => 400, @_ ) ); }
709              
710 3     3 1 410 sub is_server_error { return( shift->_min_max( 500 => 600, @_ ) ); }
711              
712 8     8 1 45551 sub is_success { return( shift->_min_max( 200 => 300, @_ ) ); }
713              
714             # Returns a status line for a given code
715             # e.g. status_message( 404 ) would yield "Not found"
716             # sub status_message { return( Apache2::RequestUtil::get_status_line( $_[1] ) ); }
717             sub status_message
718             {
719 25     25 1 2430 my $self = shift( @_ );
720 25         32 my( $code, $lang );
721 25 50       47 if( scalar( @_ ) == 2 )
722             {
723 0         0 ( $code, $lang ) = @_;
724             }
725             else
726             {
727 25         41 $code = shift( @_ );
728 25         39 $lang = 'en_GB';
729             }
730 25 50       66 $lang = 'en_GB' if( !exists( $CODES_LOCALE->{ $lang } ) );
731 25         35 my $ref = $CODES_LOCALE->{ $lang };
732 25         117 return( $ref->{ $code } );
733             }
734              
735             sub supported_languages
736             {
737 0     0 1 0 my $self = shift( @_ );
738 0         0 return( [sort( keys( %$CODES_LOCALE ) )] );
739             }
740              
741             sub _min_max
742             {
743 35     35   58 my $this = shift( @_ );
744 35         60 my( $min, $max, $code ) = @_;
745 35 100 100     244 return( $this->error( "A 3 digit code is required." ) ) if( !defined( $code ) || $code !~ /^\d{3}$/ );
746 25   100     252 return( $code >= $min && $code < $max );
747             }
748              
749             # NOTE: sub FREEZE is inherited
750              
751 1     1 0 82 sub STORABLE_freeze { CORE::return( CORE::shift->FREEZE( @_ ) ); }
752              
753 1     1 0 180 sub STORABLE_thaw { CORE::return( CORE::shift->THAW( @_ ) ); }
754              
755             # NOTE: sub THAW is inherited
756              
757             1;
758             # NOTE: POD
759             __END__
760              
761             =encoding utf-8
762              
763             =head1 NAME
764              
765             HTTP::Promise::Status - HTTP Status Codes & Locale Equivalents
766              
767             =head1 SYNOPSIS
768              
769             use HTTP::Promise::Status ':common';
770             use HTTP::Promise::Status ':all';
771             say HTTP::Promise::Status::HTTP_TOO_MANY_REQUESTS;
772             # returns code 429
773              
774             say $HTTP::Promise::Status::CODES_LOCALE->{fr_FR}->{429} # Trop de requête
775             # In Japanese: リクエスト過大で拒否した
776             say $HTTP::Promise::Status::CODES_LOCALE->{ja_JP}->{429}
777              
778             But maybe more simply:
779              
780             my $status = HTTP::Promise::Status->new;
781             say $status->status_message( 429 => 'ja_JP' );
782             # Or without the language code parameter, it will default to en_GB
783             say $status->status_message( 429 );
784              
785             # Is success
786             say $status->is_info( 102 ); # true
787             say $status->is_success( 200 ); # true
788             say $status->is_redirect( 302 ); # true
789             say $status->is_error( 404 ); # true
790             say $status->is_client_error( 403 ); # true
791             say $status->is_server_error( 501 ); # true
792              
793             =head1 VERSION
794              
795             v0.1.0
796              
797             =head1 DESCRIPTION
798              
799             This module allows the access of http constants similar to mod_perl and using their numeric value, and also allows to get the localised version of the http status for a given code for currently supported languages: fr_FR (French), en_GB (British English) and ja_JP (Japanese), de_DE (German), ko_KR (Korean), ru_RU (Russian), zh_TW (Taiwanese).
800              
801             It also provides some functions to check if a given code is an information, success, redirect, error, client error or server error code.
802              
803             =head1 METHODS
804              
805             =head2 init
806              
807             Creates an instance of L<HTTP::Promise::Status> and returns the object.
808              
809             =head2 convert_short_lang_to_long
810              
811             Given a 2 characters language code (not case sensitive) and this will return its iso 639 5 characters equivalent for supported languages.
812              
813             For example:
814              
815             HTTP::Promise::Status->convert_short_lang_to_long( 'zh' );
816             # returns: zh_TW
817              
818             =head2 is_cacheable_by_default
819              
820             Return true if the 3-digits code provided indicates that a response is cacheable by default, and it can be reused by a cache with heuristic expiration. All other status codes are not cacheable by default. See L<RFC 7231 - HTTP/1.1 Semantics and Content, Section 6.1. Overview of Status Codes|https://tools.ietf.org/html/rfc7231#section-6.1>.
821              
822             =head2 is_client_error
823              
824             Returns true if the 3-digits code provided is between 400 and 500
825              
826             =head2 is_error
827              
828             Returns true if the 3-digits code provided is between 400 and 600
829              
830             =head2 is_info
831              
832             Returns true if the 3-digits code provided is between 100 and 200
833              
834             =head2 is_redirect
835              
836             Returns true if the 3-digits code provided is between 300 and 400
837              
838             =head2 is_server_error
839              
840             Returns true if the 3-digits code provided is between 500 and 600
841              
842             =head2 is_success
843              
844             Returns true if the 3-digits code provided is between 200 and 300
845              
846             =head2 status_message
847              
848             Provided with a 3-digits http code and an optional language code such as C<en_GB> and this will return the status message in its localised form.
849              
850             This is useful to provide response to error in the user preferred language. You can also use it to set a json response with the http error code along with a localised status message.
851              
852             If no language code is provided, this will default to C<en_GB>.
853              
854             See L</supported_languages> for the supported languages.
855              
856             =head2 supported_languages
857              
858             This will return a sorted array reference of support languages for status codes.
859              
860             The following language codes are currently supported: de_DE (German), en_GB (British English), fr_FR (French), ja_JP (Japanese), ko_KR (Korean), ru_RU (Russian) and zh_TW (Traditional Chinese as spoken in Taiwan).
861              
862             Feel free to contribute those codes in other languages.
863              
864             =head1 CONSTANTS
865              
866             The following constants can be exported. You can use the C<:all> tag to export them all, such as:
867              
868             use HTTP::Promise::Status qw( :all );
869              
870             or you can use the tag C<:common> to export the following common status codes:
871              
872             HTTP_NETWORK_AUTHENTICATION_REQUIRED
873             HTTP_FORBIDDEN
874             HTTP_NOT_FOUND
875             HTTP_OK
876             HTTP_TEMPORARY_REDIRECT
877             HTTP_INTERNAL_SERVER_ERROR
878              
879             =head2 HTTP_CONTINUE (100)
880              
881             See L<rfc 7231, section 5.1.1|https://tools.ietf.org/html/rfc7231#section-5.1.1> and section L<6.2.1|https://tools.ietf.org/html/rfc7231#section-6.2.1> and L<Mozilla docs|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100>
882              
883             This is provisional response returned by the web server upon an abbreviated request to find out whether the web server will accept the actual request. For example when the client is sending a large file in chunks, such as in C<PUT> request (here a 742MB file):
884              
885             PUT /some//big/file.mp4 HTTP/1.1
886             Host: www.example.org
887             Content-Type: video/mp4
888             Content-Length: 778043392
889             Expect: 100-continue
890              
891             If the server refused, it could return a C<413 Request Entity Too Large> or C<405 Method Not Allowed> or even C<401 Unauthorized>, or even a C<417 Expectation Failed> if it does not support this feature.
892              
893             A response C<417 Expectation Failed> means the server is likely a HTTP/1.0 server or does not understand the request and the actual request must be sent, i.e. without the header field C<Expect: 100-continue>
894              
895             In some REST API implementation, the server response code C<417> is used to mean the server understood the requested, but rejected it. This is a divergent use of the original purpose of this code.
896              
897             =head2 HTTP_SWITCHING_PROTOCOLS (101)
898              
899             See L<rfc7231, section 6.2.2|https://tools.ietf.org/html/rfc7231#section-6.2.2>
900              
901             This is used to indicate that the TCP conncection is switching to a different protocol.
902              
903             This is typically used for the L<WebSocket> protocol, which uses initially a HTTP handshake when establishing the connection. For example:
904              
905             GET /chat HTTP/1.1
906             Host: server.example.com
907             Upgrade: websocket
908             Connection: Upgrade
909             Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
910             Origin: http://example.com
911             Sec-WebSocket-Protocol: chat, superchat
912             Sec-WebSocket-Version: 13
913              
914             Then the server could reply something like:
915              
916             HTTP/1.1 101 Switching Protocols
917             Upgrade: websocket
918             Connection: Upgrade
919             Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
920             Sec-WebSocket-Protocol: chat
921              
922             =head2 HTTP_PROCESSING (102)
923              
924             See L<rfc 2518 on WebDAV|https://tools.ietf.org/html/rfc2518>
925              
926             This is returned to notify the client that the server is currently processing the request and that it is taking some time.
927              
928             The server could return repeated instance of this response code until it is done processing the request and then send back the actual final response headers.
929              
930             =head2 HTTP_EARLY_HINTS (103)
931              
932             See L<rfc 8297 on Indicating Hints|https://tools.ietf.org/html/rfc8297>
933              
934             This is a preemptive return code to notify the client to make some optimisations, while the actual final response headers are sent later. For example:
935              
936             HTTP/1.1 103 Early Hints
937             Link: </style.css>; rel=preload; as=style
938             Link: </script.js>; rel=preload; as=script
939              
940             then, a few seconds, or minutes later:
941              
942             HTTP/1.1 200 OK
943             Date: Mon, 16 Apr 2022 02:15:12 GMT
944             Content-Length: 1234
945             Content-Type: text/html; charset=utf-8
946             Link: </style.css>; rel=preload; as=style
947             Link: </script.js>; rel=preload; as=script
948              
949             =head2 HTTP_OK (200)
950              
951             See L<rfc7231, section 6.3.1|https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.1>
952              
953             This is returned to inform the request has succeeded. It can also alternatively be C<204 No Content> when there is no response body.
954              
955             For example:
956              
957             HTTP/1.1 200 OK
958             Content-Type: text/html; charset=utf-8
959             Content-Length: 184
960             Connection: keep-alive
961             Cache-Control: s-maxage=300, public, max-age=0
962             Content-Language: en-US
963             Date: Mon, 18 Apr 2022 17:37:18 GMT
964             ETag: "2e77ad1dc6ab0b53a2996dfd4653c1c3"
965             Server: Apache/2.4
966             Strict-Transport-Security: max-age=63072000
967             X-Content-Type-Options: nosniff
968             X-Frame-Options: DENY
969             X-XSS-Protection: 1; mode=block
970             Vary: Accept-Encoding,Cookie
971             Age: 7
972              
973             <!DOCTYPE html>
974             <html lang="en">
975             <head>
976             <meta charset="utf-8">
977             <title>A simple webpage</title>
978             </head>
979             <body>
980             <h1>Simple HTML5 webpage</h1>
981             <p>Hello, world!</p>
982             </body>
983             </html>
984              
985             =head2 HTTP_CREATED (201)
986              
987             See L<rfc7231, section 6.3.2|https://datatracker.ietf.org/doc/html/rfc7231#section-6.3.2>
988              
989             This is returned to notify the related resource has been created, most likely by a C<PUT> request, such as:
990              
991             PUT /some/where HTTP/1.1
992             Content-Type: text/html
993             Host: example.org
994              
995             Then, the server would reply:
996              
997             HTTP/1.1 201 Created
998             ETag: "foo-bar"
999              
1000             =head2 HTTP_ACCEPTED (202)
1001              
1002             See L<rfc7231, section 6.3.3|https://tools.ietf.org/html/rfc7231#section-6.3.3>
1003              
1004             This is returned when the web server has accepted the request, without guarantee of successful completion.
1005              
1006             Thus, the remote service would typically send an email to inform the user of the status, or maybe provide a link in the header. For example:
1007              
1008             POST /some/where HTTP/1.1
1009             Content-Type: application/json
1010              
1011             Then the server response:
1012              
1013             HTTP/1.1 202 Accepted
1014             Link: </some/status/1234> rel="https://example.org/status"
1015             Content-Length: 0
1016              
1017             =head2 HTTP_NON_AUTHORITATIVE (203)
1018              
1019             See L<rfc 7231, section 6.3.4|https://tools.ietf.org/html/rfc7231#section-6.3.4>
1020              
1021             This would typically be returned by an HTTP proxy after it has made some change to the content.
1022              
1023             =head2 HTTP_NO_CONTENT (204)
1024              
1025             L<See rfc 7231, section 6.3.5|https://tools.ietf.org/html/rfc7231#section-6.3.5>
1026              
1027             This is returned when the request was processed successfully, but there is no body content returned.
1028              
1029             =head2 HTTP_RESET_CONTENT (205)
1030              
1031             L<See rfc 7231, section 6.3.6|https://tools.ietf.org/html/rfc7231#section-6.3.6>
1032              
1033             This is to inform the client the request was successfully processed and the content should be reset, like a web form.
1034              
1035             =head2 HTTP_PARTIAL_CONTENT (206)
1036              
1037             See L<rfc 7233 on Range Requests|https://tools.ietf.org/html/rfc7233>
1038              
1039             This is returned in response to a request for partial content, such as a certain number of bytes from a video. For example:
1040              
1041             GET /video.mp4 HTTP/1.1
1042             Range: bytes=1048576-2097152
1043              
1044             Then, the server would reply something like:
1045              
1046             HTTP/1.1 206 Partial Content
1047             Content-Range: bytes 1048576-2097152/3145728
1048             Content-Type: video/mp4
1049              
1050             =head2 HTTP_MULTI_STATUS (207)
1051              
1052             See L<rfc 4918 on WebDAV|https://tools.ietf.org/html/rfc4918>
1053              
1054             This is returned predominantly under the WebDav protocol, when multiple operations occurred. For example:
1055              
1056             HTTP/1.1 207 Multi-Status
1057             Content-Type: application/xml; charset="utf-8"
1058             Content-Length: 637
1059              
1060             <d:multistatus xmlns:d="DAV:">
1061             <d:response>
1062             <d:href>/calendars/johndoe/home/132456762153245.ics</d:href>
1063             <d:propstat>
1064             <d:prop>
1065             <d:getetag>"xxxx-xxx"</d:getetag>
1066             </d:prop>
1067             <d:status>HTTP/1.1 200 OK</d:status>
1068             </d:propstat>
1069             </d:response>
1070             <d:response>
1071             <d:href>/calendars/johndoe/home/fancy-caldav-client-1234253678.ics</d:href>
1072             <d:propstat>
1073             <d:prop>
1074             <d:getetag>"5-12"</d:getetag>
1075             </d:prop>
1076             <d:status>HTTP/1.1 200 OK</d:status>
1077             </d:propstat>
1078             </d:response>
1079             </d:multistatus>
1080              
1081             =head2 HTTP_ALREADY_REPORTED (208)
1082              
1083             See L<rfc 5842, section 7.1 on WebDAV bindings|https://tools.ietf.org/html/rfc5842#section-7.1>
1084              
1085             This is returned predominantly under the WebDav protocol.
1086              
1087             =head2 HTTP_IM_USED (226)
1088              
1089             See L<rfc 3229 on Delta encoding|https://tools.ietf.org/html/rfc3229>
1090              
1091             C<IM> stands for C<Instance Manipulation>.
1092              
1093             This is an HTTP protocol extension used to indicate a diff performed and return only a fraction of the resource. This is especially true when the actual resource is large and it would be a waste of bandwidth to return the entire resource. For example:
1094              
1095             GET /foo.html HTTP/1.1
1096             Host: bar.example.net
1097             If-None-Match: "123xyz"
1098             A-IM: vcdiff, diffe, gzip
1099              
1100             Then, the server would reply something like:
1101              
1102             HTTP/1.1 226 IM Used
1103             ETag: "489uhw"
1104             IM: vcdiff
1105             Date: Tue, 25 Nov 1997 18:30:05 GMT
1106             Cache-Control: no-store, im, max-age=30
1107              
1108             See also the L<HTTP range request|https://tools.ietf.org/html/rfc7233> triggering a C<206 Partial Content> response.
1109              
1110             =head2 HTTP_MULTIPLE_CHOICES (300)
1111              
1112             See L<rfc 7231, section 6.4.1|https://tools.ietf.org/html/rfc7231#section-6.4.1> and L<rfc 5988|https://tools.ietf.org/html/rfc5988> for the C<Link> header.
1113              
1114             See L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/300>
1115              
1116             This is returned when there is a redirection with multiple choices possible. For example:
1117              
1118             HTTP/1.1 300 Multiple Choices
1119             Server: Apache/2.4
1120             Access-Control-Allow-Headers: Content-Type,User-Agent
1121             Access-Control-Allow-Origin: *
1122             Link: </foo> rel="alternate"
1123             Link: </bar> rel="alternate"
1124             Content-Type: text/html
1125             Location: /foo
1126              
1127             However, because there is no standard way to have the user choose, this response code is never used.
1128              
1129             =head2 HTTP_MOVED_PERMANENTLY (301)
1130              
1131             See L<rfc 7231, section 6.4.2|https://tools.ietf.org/html/rfc7231#section-6.4.2>
1132              
1133             This is returned to indicate the target resource can now be found at a different location and all pointers should be updated accordingly. For example:
1134              
1135             HTTP/1.1 301 Moved Permanently
1136             Server: Apache/2.4
1137             Content-Type: text/html; charset=utf-8
1138             Date: Mon, 18 Apr 2022 17:33:08 GMT
1139             Location: https://example.org/some/where/else.html
1140             Keep-Alive: timeout=15, max=98
1141             Accept-Ranges: bytes
1142             Via: Moz-Cache-zlb05
1143             Connection: Keep-Alive
1144             Content-Length: 212
1145              
1146             <!DOCTYPE html>
1147             <html><head>
1148             <title>301 Moved Permanently</title>
1149             </head><body>
1150             <h1>Moved Permanently</h1>
1151             <p>The document has moved <a href="https://example.org/some/where/else.html">here</a>.</p>
1152             </body></html>
1153              
1154             See also C<308 Permanent Redirect>
1155              
1156             =head2 HTTP_MOVED_TEMPORARILY (302)
1157              
1158             See L<rfc 7231, section 6.4.3|https://tools.ietf.org/html/rfc7231#section-6.4.3>
1159              
1160             This is returned to indicate the resource was found, but somewhere else. This is to be understood as a temporary change.
1161              
1162             The de facto standard, divergent from the original intent, is to point the client to a new location after a C<POST> request was performed. This is why the status code C<307> was created.
1163              
1164             See also C<307 Temporary Redirect>, which more formally tells the client to reformulate their request to the new location.
1165              
1166             See also C<303 See Other> for a formal implementation of aforementioned de facto standard, i.e. C<GET> new location after C<POST> request.
1167              
1168             =head2 HTTP_SEE_OTHER (303)
1169              
1170             See L<rfc 7231, section 6.4.4|https://tools.ietf.org/html/rfc7231#section-6.4.4>
1171              
1172             This is returned to indicate the result of processing the request can be found at another location. For example, after a C<POST> request, such as:
1173              
1174             HTTP/1.1 303 See Other
1175             Server: Apache/2.4
1176             Location: /worked/well
1177              
1178             It is considered better to redirect once request has been processed rather than returning the result immediately in the response body, because in the former case, this wil register a new entry in the client history whereas with the former, this would force the user to re-submit if the user did a back in history.
1179              
1180             =head2 HTTP_NOT_MODIFIED (304)
1181              
1182             See L<rfc 7232, section 4.1 on Conditional Request|https://tools.ietf.org/html/rfc7232#section-4.1>
1183              
1184             This is returned in response to a conditional C<GET> or C<POST> request with headers such as:
1185              
1186             =over 4
1187              
1188             =item L<If-Match|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match>
1189              
1190             =item L<If-None-Match|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match>
1191              
1192             =item L<If-Modified-Since|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since>
1193              
1194             =item L<If-Unmodified-Since|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Unmodified-Since>
1195              
1196             =item L<If-Range|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range>
1197              
1198             =back
1199              
1200             For example:
1201              
1202             GET /foo HTTP/1.1
1203             Accept: text/html
1204              
1205             Then, the server would reply something like:
1206              
1207             HTTP/1.1 200 Ok
1208             Content-Type: text/html
1209             ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
1210              
1211             Later, the client would do another request, such as:
1212              
1213             GET /foo HTTP/1.1
1214             Accept: text/html
1215             If-None-Match: "33a64df551425fcc55e4d42a148795d9f25f89d4"
1216              
1217             And if nothing changed, the server would return something like this:
1218              
1219             HTTP/1.1 304 Not Modified
1220             ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"
1221              
1222             =head2 HTTP_USE_PROXY (305)
1223              
1224             See L<rfc 7231, section 6.4.5|https://tools.ietf.org/html/rfc7231#section-6.4.5> and the L<rfc 2616, section 10.3.6 deprecating this status code|https://tools.ietf.org/html/rfc2616#section-10.3.6>
1225              
1226             This is returned to indicate to the client to submit the request again, using a proxy. For example:
1227              
1228             HTTP/1.1 305 Use Proxy
1229             Location: https://proxy.example.org:8080/
1230              
1231             This is deprecated and is not in use.
1232              
1233             =head2 306 Switch Proxy
1234              
1235             This is deprecated and now a reserved status code that was L<originally designed|https://lists.w3.org/Archives/Public/ietf-http-wg-old/1997MayAug/0373.html> to indicate to the client the need to change proxy, but was deemed ultimately a security risk. See the original L<rfc draft|https://datatracker.ietf.org/doc/html/draft-cohen-http-305-306-responses-00>
1236              
1237             For example:
1238              
1239             HTTP/1.1 306 Switch Proxy
1240             Set-Proxy: SET; proxyURI="https://proxy.example.org:8080/" scope="http://", seconds=100
1241              
1242             =head2 HTTP_TEMPORARY_REDIRECT (307)
1243              
1244             See L<rfc 2731, section 6.4.7|https://tools.ietf.org/html/rfc7231#section-6.4.7>
1245              
1246             This is returned to indicate the client to perform the request again at a different location. The difference with status code C<302> is that the client would redirect to the new location using a C<GET> method, whereas with the status code C<307>, they have to perform the same request.
1247              
1248             For example:
1249              
1250             HTTP/1.1 307 Temporary Redirect
1251             Server: Apache/2.4
1252             Location: https://example.org/some/where/else.html
1253              
1254             =head2 HTTP_PERMANENT_REDIRECT (308)
1255              
1256             See L<rfc 7538 on Permanent Redirect|https://tools.ietf.org/html/rfc7538>
1257              
1258             Similar to the status code C<307> and C<302>, the status code C<308> indicates to the client to perform the request again at a different location and that the location has changed permanently. This echoes the status code C<301>, except that the standard with C<301> is for clients to redirect using C<GET> method even if originally the method used was C<POST>. With the status code C<308>, the client must reproduce the request with the original method.
1259              
1260             For example:
1261              
1262             GET / HTTP/1.1
1263             Host: example.org
1264              
1265             Then, the server would respond something like:
1266              
1267             HTTP/1.1 308 Permanent Redirect
1268             Server: Apache/2.4
1269             Content-Type: text/html; charset=UTF-8
1270             Location: https://example.org/some/where/else.html
1271             Content-Length: 393
1272              
1273             <!DOCTYPE HTML>
1274             <html>
1275             <head>
1276             <title>Permanent Redirect</title>
1277             <meta http-equiv="refresh"
1278             content="0; url=https://example.org/some/where/else.html">
1279             </head>
1280             <body>
1281             <p>
1282             The document has been moved to
1283             <a href="https://example.org/some/where/else.html"
1284             >https://example.org/some/where/else.html</a>.
1285             </p>
1286             </body>
1287             </html>
1288              
1289             =head2 HTTP_BAD_REQUEST (400)
1290              
1291             See L<rfc 7231, section 6.5.1|https://tools.ietf.org/html/rfc7231#section-6.5.1>
1292              
1293             This is returned to indicate the client made a request the server could not interpret.
1294              
1295             This is generally used as a fallback client-error code when other mode detailed C<4xx> code are not suitable.
1296              
1297             =head2 HTTP_UNAUTHORIZED (401)
1298              
1299             See L<rfc 7235, section 3.1 on Authentication|https://tools.ietf.org/html/rfc7235#section-3.1>
1300              
1301             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401>
1302              
1303             This is returned to indicate to the client it must authenticate first before issuing the request.
1304              
1305             See also status code C<403 Forbidden> when client is outright forbidden from accessing the resource.
1306              
1307             For example:
1308              
1309             HTTP/1.1 401 Unauthorized
1310             WWW-Authenticate: Basic; realm="Secured area"
1311              
1312             or, for APIs:
1313              
1314             HTTP/1.1 401 Unauthorized
1315             WWW-Authenticate: Bearer
1316              
1317             or, combining both:
1318              
1319             HTTP/1.1 401 Unauthorized
1320             WWW-Authenticate: Basic; realm="Dev zone", Bearer
1321              
1322             which equates to:
1323              
1324             HTTP/1.1 401 Unauthorized
1325             WWW-Authenticate: Basic; realm="Dev zone"
1326             WWW-Authenticate: Bearer
1327              
1328             So, for example, a user C<aladdin> with password C<opensesame> would result in the following request:
1329              
1330             GET / HTTP/1.1
1331             Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
1332              
1333             See also L<Mozilla documentation on Authorization header|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization>
1334              
1335             =head2 HTTP_PAYMENT_REQUIRED (402)
1336              
1337             See L<rfc 7231, section 6.5.2|https://tools.ietf.org/html/rfc7231#section-6.5.2>
1338              
1339             This was originally designed to inform the client that the resource could only be accessed once payment was made, but is now reserved and its current use is left at the discretion of the site implementing it.
1340              
1341             =head2 HTTP_FORBIDDEN (403)
1342              
1343             See L<rfc 7231, section 6.5.3|https://tools.ietf.org/html/rfc7231#section-6.5.3>
1344              
1345             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403>
1346              
1347             This is returned to indicate the client is barred from accessing the resource.
1348              
1349             This is different from C<405 Method Not Allowed>, which is used when the client has proper permission to access the resource, but is using a method not allowed, such as using C<PUT> instead of C<GET> method.
1350              
1351             =head2 HTTP_NOT_FOUND (404)
1352              
1353             See L<rfc 7231, section 6.5.4|https://tools.ietf.org/html/rfc7231#section-6.5.4>
1354              
1355             See also L<Mozilla documentation|https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404>
1356              
1357             This is returned to indicate the resource does not exist anymore.
1358              
1359             =head2 HTTP_METHOD_NOT_ALLOWED (405)
1360              
1361             See L<rfc 7231, section 6.5.5|https://tools.ietf.org/html/rfc7231#section-6.5.5>
1362              
1363             This is returned to indicate the client it used a L<method|https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods> not allowed, such as using C<PUT> instead of C<GET>. The server can point out the supported methods with the C<Allow> header, such as:
1364              
1365             HTTP/1.1 405 Method Not Allowed
1366             Content-Type: text/html
1367             Content-Length: 32
1368             Allow: GET, HEAD, OPTIONS, PUT
1369              
1370             <h1>405 Try another method!</h1>
1371              
1372             =head2 HTTP_NOT_ACCEPTABLE (406)
1373              
1374             See L<rfc 7231, section 6.5.6|https://tools.ietf.org/html/rfc7231#section-6.5.6>
1375              
1376             This is returned to the client to indicate its requirements are not supported and thus not acceptable. This is in response to L<Accept|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept>, L<Accept-Charset|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Charset>, L<Accept-Encoding|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding>, L<Accept-Language|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language> headers
1377              
1378             For example:
1379              
1380             GET /foo HTTP/1.1
1381             Accept: application/json
1382             Accept-Language: fr-FR,en-GB;q=0.8,fr;q=0.6,en;q=0.4,ja;q=0.2
1383              
1384             HTTP/1.1 406 Not Acceptable
1385             Server: Apache/2.4
1386             Content-Type: text/html
1387              
1388             <h1>Je ne gère pas le type application/json</h1>
1389              
1390              
1391             Then, the server would response something like:
1392              
1393             =head2 HTTP_PROXY_AUTHENTICATION_REQUIRED (407)
1394              
1395             See L<rfc 7235, section 3.2 on Authentication|https://tools.ietf.org/html/rfc7235#section-3.2>
1396              
1397             This is returned to indicate the proxy used requires authentication. This is similar to the status code C<401 Unauthorized>.
1398              
1399             =head2 HTTP_REQUEST_TIME_OUT (408)
1400              
1401             See L<rfc 7231, section 6.5.7|https://tools.ietf.org/html/rfc7231#section-6.5.7>
1402              
1403             This is returned to indicate the request took too long to be received and timed out. For example:
1404              
1405             HTTP/1.1 408 Request Timeout
1406             Connection: close
1407             Content-Type: text/plain
1408             Content-Length: 19
1409              
1410             Too slow! Try again
1411              
1412             =head2 HTTP_CONFLICT (409)
1413              
1414             See L<rfc 7231, section 6.5.8|https://tools.ietf.org/html/rfc7231#section-6.5.8>
1415              
1416             This is returned to indicate a request conflict with the current state of the target resource, such as uploading with C<PUT> a file older than the remote one.
1417              
1418             =head2 HTTP_GONE (410)
1419              
1420             See L<rfc 7231, section 6.5.9|https://tools.ietf.org/html/rfc7231#section-6.5.9>
1421              
1422             This is returned to indicate that the target resource is gone permanently. The subtle difference with the status code C<404> is that with C<404>, the resource may be only temporally unavailable whereas with C<410>, this is irremediable. For example:
1423              
1424             HTTP/1.1 410 Gone
1425             Server: Apache/2.4
1426             Content-Type: text/plain
1427             Content-Length: 30
1428              
1429             The resource has been removed.
1430              
1431             =head2 HTTP_LENGTH_REQUIRED (411)
1432              
1433             See L<rfc 7231, section 6.5.10|https://tools.ietf.org/html/rfc7231#section-6.5.10>
1434              
1435             This is returned when the C<Content-Length> header was not provided by the client and the server requires it to be present. Most servers can do without.
1436              
1437             =head2 HTTP_PRECONDITION_FAILED (412)
1438              
1439             See L<rfc 7232 on Conditional Request|https://tools.ietf.org/html/rfc7232>
1440              
1441             This is returned when some preconditions set by the client could not be met.
1442              
1443             For example:
1444              
1445             Issuing a C<PUT> request for a document if it does not already exist.
1446              
1447             PUT /foo/new-article.md HTTP/1.1
1448             Content-Type: text/markdown
1449             If-None-Match: *
1450              
1451             Update a document if it has not changed since last time (etag)
1452              
1453             PUT /foo/old-article.md HTTP/1.1
1454             If-Match: "1345-12315"
1455             Content-Type: text/markdown
1456              
1457             If those failed, it would return something like:
1458              
1459             HTTP/1.1 412 Precondition Failed
1460             Content-Type: text/plain
1461             Content-Length: 64
1462              
1463             The article you are tring to update has changed since last time.
1464              
1465             If one adds the C<Prefer> header, the servers will return the current state of the resource, thus saving a round of request with a C<GET>, such as:
1466              
1467             PUT /foo/old-article.md HTTP/1.1
1468             If-Match: "1345-12315"
1469             Content-Type: text/markdown
1470             Prefer: return=representation
1471              
1472             ### Article version 2.1
1473              
1474             Then, the server would respond something like:
1475              
1476             HTTP/1.1 412 Precondition Failed
1477             Content-Type: text/markdown
1478             Etag: "4444-12345"
1479             Vary: Prefer
1480              
1481             ### Article version 3.0
1482              
1483             See also L<rfc 7240 about the Prefer header field|https://tools.ietf.org/html/rfc7240> and L<rfc 8144, Section 3.2|https://tools.ietf.org/html/rfc8144#section-3.2> about the usage of C<Prefer: return=representation> with status code C<412>
1484              
1485             =head2 HTTP_REQUEST_ENTITY_TOO_LARGE (413)
1486              
1487             See L<rfc 7231, section 6.5.11|https://tools.ietf.org/html/rfc7231#section-6.5.11>
1488              
1489             This is returned when the body of the request is too large, such as when sending a file whose size has exceeded the maximum size limit.
1490              
1491             For example:
1492              
1493             HTTP/1.1 413 Payload Too Large
1494             Retry-After: 3600
1495             Content-Type: text/html
1496             Content-Length: 52
1497              
1498             <p>You exceeded your quota. Try again in an hour</p>
1499              
1500             See also L<rfc 7231, section 7.1.3|https://tools.ietf.org/html/rfc7231#section-7.1.3> on C<Retry-After> header field.
1501              
1502             See also C<507 Insufficient Storage>
1503              
1504             =head2 HTTP_PAYLOAD_TOO_LARGE (413)
1505              
1506             Same as previous. Used here for compatibility with HTTP::Status
1507              
1508             =head2 HTTP_REQUEST_URI_TOO_LARGE (414)
1509              
1510             See L<rfc 7231, section 6.5.12|https://tools.ietf.org/html/rfc7231#section-6.5.12>
1511              
1512             Although there is no official limit to the size of an URI, some servers may implement a limit and return this status code when the URI exceeds it. Usually, it is recommended not to exceed 2048 bytes for an URI.
1513              
1514             =head2 HTTP_UNSUPPORTED_MEDIA_TYPE (415)
1515              
1516             See L<rfc 7231, section 6.5.13|https://tools.ietf.org/html/rfc7231#section-6.5.13>
1517              
1518             This is returned when the server received a request body type it does not understand.
1519              
1520             This status code may be returned even if the C<Content-Type> header value is supported, because the server would still inspect the request body, such as with a broken C<JSON> payload.
1521              
1522             Usually, in those cases, the server would rather return C<422 Unprocessable Entity>
1523              
1524             =head2 HTTP_RANGE_NOT_SATISFIABLE (416)
1525              
1526             See L<rfc 7233, section 4.4 on Range Requests|https://tools.ietf.org/html/rfc7233#section-4.4>
1527              
1528             This is returned when the client made a range request it did not understand.
1529              
1530             Client can issue range request instead of downloading the entire file, which is helpful for large data.
1531              
1532             =head2 HTTP_REQUEST_RANGE_NOT_SATISFIABLE (416)
1533              
1534             Same as previous. Used here for compatibility with HTTP::Status
1535              
1536             =head2 HTTP_EXPECTATION_FAILED (417)
1537              
1538             See L<rfc 7231, section 6.5.14|https://tools.ietf.org/html/rfc7231#section-6.5.14>
1539              
1540             This is returned when the server received an C<Expect> header field value it did not understand.
1541              
1542             For example:
1543              
1544             PUT /some//big/file.mp4 HTTP/1.1
1545             Host: www.example.org
1546             Content-Type: video/mp4
1547             Content-Length: 778043392
1548             Expect: 100-continue
1549              
1550             Then, the server could respond with the following:
1551              
1552             HTTP/1.1 417 Expectation Failed
1553             Server: Apache/2.4
1554             Content-Type: text/plain
1555             Content-Length: 30
1556              
1557             We do not support 100-continue
1558              
1559             See also L<rfc 7231, section 5.1.1|https://tools.ietf.org/html/rfc7231#section-5.1.1> on the C<Expect> header.
1560              
1561             =head2 HTTP_I_AM_A_TEAPOT (418)
1562              
1563             See L<rfc 2324 on HTCPC/1.0 1-april|https://tools.ietf.org/html/rfc2324>
1564              
1565             This status code is not actually a real one, but one that was made by the IETF as an april-fools' joke, and it stuck. Attempts to remove it was met with L<strong resistance|https://save418.com/>.
1566              
1567             There has even been L<libraries developed|https://github.com/dkundel/htcpcp-delonghi> to implement the L<HTCPC protocol|https://github.com/HyperTextCoffeePot/HyperTextCoffeePot>.
1568              
1569             =head2 HTTP_I_AM_A_TEA_POT (418)
1570              
1571             Same as previous.
1572              
1573             =head2 HTTP_MISDIRECTED_REQUEST (421)
1574              
1575             See L<rfc 7540, section 9.1.2 on HTTP/2|https://tools.ietf.org/html/rfc7540#section-9.1.2>
1576              
1577             This is returned when the web server received a request that was not intended for him.
1578              
1579             For example:
1580              
1581             GET /contact.html HTTP/1.1
1582             Host: foo.example.org
1583              
1584             HTTP/1.1 421 Misdirected Request
1585             Content-Type: text/plain
1586             Content-Length: 27
1587              
1588             This host unsupported here.
1589              
1590             =head2 HTTP_UNPROCESSABLE_ENTITY (422)
1591              
1592             See L<rfc 4918, section 11.2|https://tools.ietf.org/html/rfc4918#section-11.2>
1593              
1594             This is returned when the web server understood the request, but deemed the body content to not be processable.
1595              
1596             For example:
1597              
1598             POST /new-article HTTP/1.1
1599             Content-Type: application/json
1600             Content-Length: 26
1601              
1602             { "title": "Hello world!"}
1603              
1604             Then, the web server could respond something like:
1605              
1606             HTTP/1.1 422 Unprocessable Entity
1607             Content-Type: application/problem+json
1608             Content-Length: 114
1609              
1610             {
1611             "type" : "https://example.org/errors/missing-property",
1612             "status": 422,
1613             "title": "Missing property: body"
1614             }
1615              
1616             =head2 HTTP_LOCKED (423)
1617              
1618             See L<rfc 4918 on WebDAV|https://tools.ietf.org/html/rfc4918>
1619              
1620             This is returned under the WebDav protocol when one tries to make change to a locked resource.
1621              
1622             =head2 HTTP_FAILED_DEPENDENCY (424)
1623              
1624             See L<rfc 4918 on WebDAV|https://tools.ietf.org/html/rfc4918>
1625              
1626             This is returned under the WebDav protocol when the processing of one of the resources failed.
1627              
1628             =head2 HTTP_TOO_EARLY (425)
1629              
1630             See L<rfc 8470, section 5.2 on Using Early Data in HTTP|https://tools.ietf.org/html/rfc8470#section-5.2>
1631              
1632             This predominantly occurs during the TLS handshake to notify the client to retry a bit later once the TLS connection is up.
1633              
1634             =head2 HTTP_NO_CODE (425)
1635              
1636             Same as previous. Used here for compatibility with HTTP::Status
1637              
1638             =head2 HTTP_UNORDERED_COLLECTION (425)
1639              
1640             Same as previous. Used here for compatibility with HTTP::Status
1641              
1642             =head2 HTTP_UPGRADE_REQUIRED (426)
1643              
1644             See L<rfc 7231, section 6.5.15|https://tools.ietf.org/html/rfc7231#section-6.5.15>
1645              
1646             This is returned to notify the client to use a newer version of the HTTP protocol.
1647              
1648             =head2 HTTP_PRECONDITION_REQUIRED (428)
1649              
1650             See L<rfc 6585, section 3 on Additional Codes|https://tools.ietf.org/html/rfc6585#section-3>
1651              
1652             This is used when the web server requires the client to use condition requests, such as:
1653              
1654             =over 4
1655              
1656             =item L<If-Match|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match>
1657              
1658             =item L<If-None-Match|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-None-Match>
1659              
1660             =item L<If-Modified-Since|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Modified-Since>
1661              
1662             =item L<If-Unmodified-Since|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Unmodified-Since>
1663              
1664             =item L<If-Range|https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range>
1665              
1666             =back
1667              
1668             =head2 HTTP_TOO_MANY_REQUESTS (429)
1669              
1670             See L<rfc 6585, section 4 on Additional Codes|https://tools.ietf.org/html/rfc6585#section-4>
1671              
1672             This is returned when the server needs to notify the client to slow down the number of requests. This is predominantly used for API, but not only.
1673              
1674             For example:
1675              
1676             HTTP/1.1 429 Too Many Requests
1677             Content-Type: text/plain
1678             Content-Length: 44
1679             Retry-After: 3600
1680              
1681             You exceeded the limit. Try again in an hour
1682              
1683             =head2 HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE (431)
1684              
1685             See L<rfc 6585, section 5 on Additional Codes|https://tools.ietf.org/html/rfc6585#section-5>
1686              
1687             This is returned when the client issued a request containing HTTP header fields that are too big in size. Most likely culprit are the HTTP cookies.
1688              
1689             =head2 HTTP_CONNECTION_CLOSED_WITHOUT_RESPONSE (444)
1690              
1691             This is a non-standard status code used by some web servers, such as nginx, to instruct it to close the connection without sending a response back to the client, predominantly to deny malicious or malformed requests.
1692              
1693             This status code is actually not seen by the client, but only appears in nginx log files.
1694              
1695             =head2 HTTP_UNAVAILABLE_FOR_LEGAL_REASONS (451)
1696              
1697             See L<rfc 7725 on Legal Obstacles|https://tools.ietf.org/html/rfc7725>
1698              
1699             This is returned when, for some legal reasons, the resource could not be served.
1700              
1701             This status code has been chosen on purpose, for its relation with the book L<Fahrenheit 451|https://en.wikipedia.org/wiki/Fahrenheit_451> from Ray Bradbury. In his book, the central theme is the censorship of literature. The book title itself "Fahrenheit 451" refers to the temperature at which paper ignites, i.e. 451 Fahrenheit or 232° Celsius.
1702              
1703             For example:
1704              
1705             HTTP/1.1 451 Unavailable For Legal Reasons
1706             Link: <https://example.org/legal>; rel="blocked-by"
1707             Content-Type text/plain
1708             Content-Length: 48
1709              
1710             You are prohibited from accessing this resource.
1711              
1712             =head2 HTTP_CLIENT_CLOSED_REQUEST (499)
1713              
1714             This is a non-standard status code used by some web servers, such as nginx, when the client has closed the connection while the web server was still processing the request.
1715              
1716             This status code is actually not seen by the client, but only appears in nginx log files.
1717              
1718             =head2 HTTP_INTERNAL_SERVER_ERROR (500)
1719              
1720             See L<rfc 7231, section 6.6.1|https://tools.ietf.org/html/rfc7231#section-6.6.1>
1721              
1722             This is returned when an internal malfunction due to some bug of general processing error.
1723              
1724             =head2 HTTP_NOT_IMPLEMENTED (501)
1725              
1726             See L<rfc 7231, section 6.6.2|https://tools.ietf.org/html/rfc7231#section-6.6.2>
1727              
1728             This is returned when the web server unexpectedly does not support certain features, although the request was itself acceptable.
1729              
1730             =head2 HTTP_BAD_GATEWAY (502)
1731              
1732             See L<rfc 7231, section 6.6.3|https://tools.ietf.org/html/rfc7231#section-6.6.3>
1733              
1734             This is returned by proxy servers when the original target server is not operating properly and to notify the client of this.
1735              
1736             =head2 HTTP_SERVICE_UNAVAILABLE (503)
1737              
1738             See L<rfc 7231, section 6.6.4|https://tools.ietf.org/html/rfc7231#section-6.6.4>
1739              
1740             This is returned when the web server is temporally incapable of processing the request, such as due to overload.
1741              
1742             For example:
1743              
1744             HTTP/1.1 503 Service Unavailable
1745             Content-Type text/plain
1746             Content-Length: 56
1747             Retry-After: 1800
1748              
1749             System overload! Give us some time to increase capacity.
1750              
1751             =head2 HTTP_GATEWAY_TIME_OUT (504)
1752              
1753             See L<rfc 7231, section 6.6.5|https://tools.ietf.org/html/rfc7231#section-6.6.5>
1754              
1755             This is returned by a proxy server when the upstream target server is not responding in a timely manner.
1756              
1757             =head2 HTTP_VERSION_NOT_SUPPORTED (505)
1758              
1759             See L<rfc 7231, section 6.6.6|https://tools.ietf.org/html/rfc7231#section-6.6.6>
1760              
1761             This is returned when the web server does not support the HTTP version submitted by the client.
1762              
1763             For example:
1764              
1765             GET / HTTP/4.0
1766             Host: www.example.org
1767              
1768             Then, the server would respond something like:
1769              
1770             HTTP/1.1 505 HTTP Version Not Supported
1771             Server: Apache/2.4
1772             Date: Mon, 18 Apr 2022 15:23:35 GMT
1773             Content-Type: text/plain
1774             Content-Length: 30
1775             Connection: close
1776              
1777             505 HTTP Version Not Supported
1778              
1779             =head2 HTTP_VARIANT_ALSO_VARIES (506)
1780              
1781             See L<rfc 2295 on Transparant Ngttn|https://tools.ietf.org/html/rfc2295>
1782              
1783             This is returned in the context of Transparent Content Negotiation when there is a server-side misconfiguration that leads the chosen variant itself to also engage in content negotiation, thus looping.
1784              
1785             For example:
1786              
1787             GET / HTTP/1.1
1788             Host: www.example.org
1789             Accept: text/html; image/png; text/*; q=0.9
1790             Accept-Language: en-GB; en
1791             Accept-Charset: UTF-8
1792             Accept-Encoding: gzip, deflate, br
1793              
1794             =head2 HTTP_INSUFFICIENT_STORAGE (507)
1795              
1796             See L<rfc 4918, section 11.5 on WebDAV|https://tools.ietf.org/html/rfc4918#section-11.5>
1797              
1798             This is returned in the context of WebDav protocol when a C<POST> or C<PUT> request leads to storing data, but the operations fails, because the resource is too large to fit on the remaining space on the server disk.
1799              
1800             =head2 HTTP_LOOP_DETECTED (508)
1801              
1802             See L<rfc 5842, section 7.2 on WebDAV bindings|https://tools.ietf.org/html/rfc5842#section-7.2>
1803              
1804             This is returned in the context of WebDav when the target resource is looping.
1805              
1806             =head2 HTTP_BANDWIDTH_LIMIT_EXCEEDED (509)
1807              
1808             This is returned by some web servers when the amount of bandwidth consumed exceeded the maximum possible.
1809              
1810             =head2 HTTP_NOT_EXTENDED (510)
1811              
1812             See L<rfc 2774, section 6 on Extension Framework|https://tools.ietf.org/html/rfc2774#section-6>
1813              
1814             This is returned by the web server who expected the client to use an extended http feature, but did not.
1815              
1816             This is not widely implemented.
1817              
1818             =head2 HTTP_NETWORK_AUTHENTICATION_REQUIRED (511)
1819              
1820             See L<rfc 6585, section 6.1 on Additional Codes|https://tools.ietf.org/html/rfc6585#section-6.1>
1821              
1822             This is returned by web server on private network to notify the client that a prior authentication is required to be able to browse the web. This is most likely used in location with private WiFi, such as lounges.
1823              
1824             =head2 HTTP_NETWORK_CONNECT_TIMEOUT_ERROR (599)
1825              
1826             This is returned by some proxy servers to signal a network connect timeout behind the proxy and the upstream target server.
1827              
1828             This is not part of the standard.
1829              
1830             =head1 AUTHOR
1831              
1832             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
1833              
1834             =head2 SEE ALSO
1835              
1836             L<IANA HTTP codes list|http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml>, L<rfc7231|https://tools.ietf.org/html/rfc7231>
1837              
1838             L<HTTP::Promise>, L<HTTP::Promise::Request>, L<HTTP::Promise::Response>, L<HTTP::Promise::Message>, L<HTTP::Promise::Entity>, L<HTTP::Promise::Headers>, L<HTTP::Promise::Body>, L<HTTP::Promise::Body::Form>, L<HTTP::Promise::Body::Form::Data>, L<HTTP::Promise::Body::Form::Field>, L<HTTP::Promise::Status>, L<HTTP::Promise::MIME>, L<HTTP::Promise::Parser>, L<HTTP::Promise::IO>, L<HTTP::Promise::Stream>, L<HTTP::Promise::Exception>
1839              
1840             =head1 COPYRIGHT & LICENSE
1841              
1842             Copyright(c) 2022 DEGUEST Pte. Ltd.
1843              
1844             All rights reserved.
1845              
1846             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1847              
1848             =cut
1849