UNPKG

swn-http-status

Version:

HTTPステータスコードをマジックナンバー化せずに扱えるシンプルなクラス。

331 lines (330 loc) 12.2 kB
class HTTPStatus { /** * @brief HTTPステータスコードの名前を取得します。 * @details このメソッドは、HTTPステータスコードに対応する名前を返します。 * @param statusCode - HTTPステータスコード * @returns ステータスコードに対応する名前、または未定義 */ static Name(statusCode) { return Object.getOwnPropertyNames(HTTPStatus) .filter(name => { var _a; return typeof ((_a = Object.getOwnPropertyDescriptor(HTTPStatus, name)) === null || _a === void 0 ? void 0 : _a.get) === "function"; }) .find(name => HTTPStatus[name] === statusCode); } /** * @brief 100 Continue * @details サーバーはリクエストヘッダーを受信し、クライアントはリクエストを続行できます。 */ static get Continue() { return 100; } /** * @brief 101 Switching Protocols * @details サーバーがプロトコルの切り替えを承認したことを示します。 */ static get SwitchingProtocols() { return 101; } /** * @brief 102 Processing * @details WebDAV拡張。リクエストの処理が継続中であることを示します。 */ static get Processing() { return 102; } /** * @brief 103 Early Hints * @details レスポンスヘッダーの早期通知に使用されます。 */ static get EarlyHints() { return 103; } /** * @brief 200 OK * @details リクエストが正常に成功しました。 */ static get OK() { return 200; } /** * @brief 201 Created * @details 新しいリソースが作成されました。 */ static get Created() { return 201; } /** * @brief 202 Accepted * @details リクエストは受理されましたが、まだ処理されていません。 */ static get Accepted() { return 202; } /** * @brief 203 Non-Authoritative Information * @details オリジンサーバー以外からの情報を返します。 */ static get NonAuthoritativeInformation() { return 203; } /** * @brief 204 No Content * @details レスポンスボディがありません。 */ static get NoContent() { return 204; } /** * @brief 205 Reset Content * @details クライアントはフォームなどをリセットする必要があります。 */ static get ResetContent() { return 205; } /** * @brief 206 Partial Content * @details 部分的なレスポンスを返します(範囲リクエスト)。 */ static get PartialContent() { return 206; } /** * @brief 207 Multi-Status * @details WebDAV拡張。複数のステータスを返します。 */ static get MultiStatus() { return 207; } /** * @brief 208 Already Reported * @details WebDAV拡張。すでに報告済みのリソースです。 */ static get AlreadyReported() { return 208; } /** * @brief 226 IM Used * @details インスタントメッセージングで使用される拡張コードです。 */ static get IMUsed() { return 226; } /** * @brief 300 Multiple Choices * @details 複数の選択肢が存在します。 */ static get MultipleChoices() { return 300; } /** * @brief 301 Moved Permanently * @details リソースが恒久的に移動しました。 */ static get MovedPermanently() { return 301; } /** * @brief 302 Found * @details リソースが一時的に移動しました。 */ static get Found() { return 302; } /** * @brief 303 See Other * @details 他のURIを参照してください。 */ static get SeeOther() { return 303; } /** * @brief 304 Not Modified * @details リソースは変更されていません。 */ static get NotModified() { return 304; } /** * @brief 305 Use Proxy * @details プロキシを使用する必要があります。 */ static get UseProxy() { return 305; } /** * @brief 307 Temporary Redirect * @details 一時的にリダイレクトされます。 */ static get TemporaryRedirect() { return 307; } /** * @brief 308 Permanent Redirect * @details 恒久的にリダイレクトされます。 */ static get PermanentRedirect() { return 308; } /** * @brief 400 Bad Request * @details サーバーがリクエストを理解できません。不正な構文やパラメータの場合に返されます。 */ static get BadRequest() { return 400; } /** * @brief 401 Unauthorized * @details 認証が必要ですが、認証情報が提供されていないか無効です。 */ static get Unauthorized() { return 401; } /** * @brief 402 Payment Required * @details 支払いが必要な場合に使用されます(現在は予約されています)。 */ static get PaymentRequired() { return 402; } /** * @brief 403 Forbidden * @details サーバーがリクエストを理解したが、権限がないため拒否されました。 */ static get Forbidden() { return 403; } /** * @brief 404 Not Found * @details サーバーは要求されたリソースを見つけることができません。ブラウザでは、これはURLが認識されないことを意味します。 */ static get NotFound() { return 404; } /** * @brief 405 Method Not Allowed * @details リクエストメソッドがサポートされていません。 */ static get MethodNotAllowed() { return 405; } /** * @brief 406 Not Acceptable * @details リクエストしたリソースがAcceptヘッダーで許可されていません。 */ static get NotAcceptable() { return 406; } /** * @brief 407 Proxy Authentication Required * @details プロキシ認証が必要です。 */ static get ProxyAuthenticationRequired() { return 407; } /** * @brief 408 Request Timeout * @details サーバーがクライアントからのリクエストをタイムアウトしました。 */ static get RequestTimeout() { return 408; } /** * @brief 409 Conflict * @details リクエストが現在のリソースの状態と競合しています。 */ static get Conflict() { return 409; } /** * @brief 410 Gone * @details リクエストされたリソースは恒久的に削除されました。 */ static get Gone() { return 410; } /** * @brief 411 Length Required * @details Content-Lengthヘッダーが必要です。 */ static get LengthRequired() { return 411; } /** * @brief 412 Precondition Failed * @details 前提条件が失敗しました。 */ static get PreconditionFailed() { return 412; } /** * @brief 413 Payload Too Large * @details リクエストペイロードが大きすぎます。 */ static get PayloadTooLarge() { return 413; } /** * @brief 414 URI Too Long * @details リクエストURIが長すぎます。 */ static get URITooLong() { return 414; } /** * @brief 415 Unsupported Media Type * @details サポートされていないメディアタイプです。 */ static get UnsupportedMediaType() { return 415; } /** * @brief 416 Range Not Satisfiable * @details リクエストした範囲が満たせません。 */ static get RangeNotSatisfiable() { return 416; } /** * @brief 417 Expectation Failed * @details Expectヘッダーで指定された期待値にサーバーが応えられません。 */ static get ExpectationFailed() { return 417; } /** * @brief 418 I'm a teapot * @details エイプリルフールのジョークコードです。ティーポットはコーヒーを淹れられません。 */ static get ImATeapot() { return 418; } /** * @brief 421 Misdirected Request * @details リクエストが誤ったサーバーに送信されました。 */ static get MisdirectedRequest() { return 421; } /** * @brief 422 Unprocessable Entity * @details リクエストは理解できたが処理できません(バリデーションエラー等)。 */ static get UnprocessableEntity() { return 422; } /** * @brief 423 Locked * @details リソースがロックされています。 */ static get Locked() { return 423; } /** * @brief 424 Failed Dependency * @details 依存関係の失敗によりリクエストが失敗しました。 */ static get FailedDependency() { return 424; } /** * @brief 425 Too Early * @details リクエストが早すぎます。 */ static get TooEarly() { return 425; } /** * @brief 426 Upgrade Required * @details プロトコルのアップグレードが必要です。 */ static get UpgradeRequired() { return 426; } /** * @brief 428 Precondition Required * @details 前提条件が必要です。 */ static get PreconditionRequired() { return 428; } /** * @brief 429 Too Many Requests * @details リクエストが多すぎます(レートリミット)。 */ static get TooManyRequests() { return 429; } /** * @brief 431 Request Header Fields Too Large * @details リクエストヘッダーが大きすぎます。 */ static get RequestHeaderFieldsTooLarge() { return 431; } /** * @brief 451 Unavailable For Legal Reasons * @details 法的理由により利用できません。 */ static get UnavailableForLegalReasons() { return 451; } /** * @brief 500 Internal Server Error * @details サーバー内部で予期しないエラーが発生しました。 */ static get InternalServerError() { return 500; } /** * @brief 501 Not Implemented * @details サーバーがリクエストされた機能を実装していません。 */ static get NotImplemented() { return 501; } /** * @brief 502 Bad Gateway * @details サーバーが不正なレスポンスを受け取りました。 */ static get BadGateway() { return 502; } /** * @brief 503 Service Unavailable * @details サービスが一時的に利用できません。 */ static get ServiceUnavailable() { return 503; } /** * @brief 504 Gateway Timeout * @details ゲートウェイまたはプロキシがタイムアウトしました。 */ static get GatewayTimeout() { return 504; } /** * @brief 505 HTTP Version Not Supported * @details サーバーがリクエストされたHTTPバージョンをサポートしていません。 */ static get HTTPVersionNotSupported() { return 505; } /** * @brief 506 Variant Also Negotiates * @details ネゴシエーションエラーが発生しました。 */ static get VariantAlsoNegotiates() { return 506; } /** * @brief 507 Insufficient Storage * @details サーバーのストレージ容量が不足しています。 */ static get InsufficientStorage() { return 507; } /** * @brief 508 Loop Detected * @details サーバーが無限ループを検出しました。 */ static get LoopDetected() { return 508; } /** * @brief 510 Not Extended * @details 拡張が必要です。 */ static get NotExtended() { return 510; } /** * @brief 511 Network Authentication Required * @details ネットワーク認証が必要です。 */ static get NetworkAuthenticationRequired() { return 511; } } export default HTTPStatus; // CommonJS対応 // @ts-ignore: node.js互換性のCommonJSエクスポートを許可します if (typeof module !== "undefined" && typeof module.exports !== "undefined") { // @ts-ignore: node.js互換性のCommonJSエクスポートを許可します module.exports = HTTPStatus; }