/** * Contains the {@linkcode STATUS_CODE} object which contains standard HTTP * status codes and provides several type guards for handling status codes * with type safety. * * @example * ```ts * import { * STATUS_CODE, * STATUS_TEXT, * } from "https://deno.land/std@$STD_VERSION/http/status.ts"; * * console.log(STATUS_CODE.NotFound); // Returns 404 * console.log(STATUS_TEXT[STATUS_CODE.NotFound]); // Returns "Not Found" * ``` * * @example * ```ts * import { isErrorStatus } from "https://deno.land/std@$STD_VERSION/http/status.ts"; * * const res = await fetch("https://example.com/"); * * if (isErrorStatus(res.status)) { * // error handling here... * } * ``` * * @module */ /** * Standard HTTP status codes. */ export declare enum Status { /** RFC 7231, 6.2.1 */ Continue = 100, /** RFC 7231, 6.2.2 */ SwitchingProtocols = 101, /** RFC 2518, 10.1 */ Processing = 102, /** RFC 8297 **/ EarlyHints = 103, /** RFC 7231, 6.3.1 */ OK = 200, /** RFC 7231, 6.3.2 */ Created = 201, /** RFC 7231, 6.3.3 */ Accepted = 202, /** RFC 7231, 6.3.4 */ NonAuthoritativeInfo = 203, /** RFC 7231, 6.3.5 */ NoContent = 204, /** RFC 7231, 6.3.6 */ ResetContent = 205, /** RFC 7233, 4.1 */ PartialContent = 206, /** RFC 4918, 11.1 */ MultiStatus = 207, /** RFC 5842, 7.1 */ AlreadyReported = 208, /** RFC 3229, 10.4.1 */ IMUsed = 226, /** RFC 7231, 6.4.1 */ MultipleChoices = 300, /** RFC 7231, 6.4.2 */ MovedPermanently = 301, /** RFC 7231, 6.4.3 */ Found = 302, /** RFC 7231, 6.4.4 */ SeeOther = 303, /** RFC 7232, 4.1 */ NotModified = 304, /** RFC 7231, 6.4.5 */ UseProxy = 305, /** RFC 7231, 6.4.7 */ TemporaryRedirect = 307, /** RFC 7538, 3 */ PermanentRedirect = 308, /** RFC 7231, 6.5.1 */ BadRequest = 400, /** RFC 7235, 3.1 */ Unauthorized = 401, /** RFC 7231, 6.5.2 */ PaymentRequired = 402, /** RFC 7231, 6.5.3 */ Forbidden = 403, /** RFC 7231, 6.5.4 */ NotFound = 404, /** RFC 7231, 6.5.5 */ MethodNotAllowed = 405, /** RFC 7231, 6.5.6 */ NotAcceptable = 406, /** RFC 7235, 3.2 */ ProxyAuthRequired = 407, /** RFC 7231, 6.5.7 */ RequestTimeout = 408, /** RFC 7231, 6.5.8 */ Conflict = 409, /** RFC 7231, 6.5.9 */ Gone = 410, /** RFC 7231, 6.5.10 */ LengthRequired = 411, /** RFC 7232, 4.2 */ PreconditionFailed = 412, /** RFC 7231, 6.5.11 */ RequestEntityTooLarge = 413, /** RFC 7231, 6.5.12 */ RequestURITooLong = 414, /** RFC 7231, 6.5.13 */ UnsupportedMediaType = 415, /** RFC 7233, 4.4 */ RequestedRangeNotSatisfiable = 416, /** RFC 7231, 6.5.14 */ ExpectationFailed = 417, /** RFC 7168, 2.3.3 */ Teapot = 418, /** RFC 7540, 9.1.2 */ MisdirectedRequest = 421, /** RFC 4918, 11.2 */ UnprocessableEntity = 422, /** RFC 4918, 11.3 */ Locked = 423, /** RFC 4918, 11.4 */ FailedDependency = 424, /** RFC 8470, 5.2 */ TooEarly = 425, /** RFC 7231, 6.5.15 */ UpgradeRequired = 426, /** RFC 6585, 3 */ PreconditionRequired = 428, /** RFC 6585, 4 */ TooManyRequests = 429, /** RFC 6585, 5 */ RequestHeaderFieldsTooLarge = 431, /** RFC 7725, 3 */ UnavailableForLegalReasons = 451, /** RFC 7231, 6.6.1 */ InternalServerError = 500, /** RFC 7231, 6.6.2 */ NotImplemented = 501, /** RFC 7231, 6.6.3 */ BadGateway = 502, /** RFC 7231, 6.6.4 */ ServiceUnavailable = 503, /** RFC 7231, 6.6.5 */ GatewayTimeout = 504, /** RFC 7231, 6.6.6 */ HTTPVersionNotSupported = 505, /** RFC 2295, 8.1 */ VariantAlsoNegotiates = 506, /** RFC 4918, 11.5 */ InsufficientStorage = 507, /** RFC 5842, 7.2 */ LoopDetected = 508, /** RFC 2774, 7 */ NotExtended = 510, /** RFC 6585, 6 */ NetworkAuthenticationRequired = 511 } export declare const STATUS_CODE: { /** RFC 7231, 6.2.1 */ readonly Continue: 100; /** RFC 7231, 6.2.2 */ readonly SwitchingProtocols: 101; /** RFC 2518, 10.1 */ readonly Processing: 102; /** RFC 8297 **/ readonly EarlyHints: 103; /** RFC 7231, 6.3.1 */ readonly OK: 200; /** RFC 7231, 6.3.2 */ readonly Created: 201; /** RFC 7231, 6.3.3 */ readonly Accepted: 202; /** RFC 7231, 6.3.4 */ readonly NonAuthoritativeInfo: 203; /** RFC 7231, 6.3.5 */ readonly NoContent: 204; /** RFC 7231, 6.3.6 */ readonly ResetContent: 205; /** RFC 7233, 4.1 */ readonly PartialContent: 206; /** RFC 4918, 11.1 */ readonly MultiStatus: 207; /** RFC 5842, 7.1 */ readonly AlreadyReported: 208; /** RFC 3229, 10.4.1 */ readonly IMUsed: 226; /** RFC 7231, 6.4.1 */ readonly MultipleChoices: 300; /** RFC 7231, 6.4.2 */ readonly MovedPermanently: 301; /** RFC 7231, 6.4.3 */ readonly Found: 302; /** RFC 7231, 6.4.4 */ readonly SeeOther: 303; /** RFC 7232, 4.1 */ readonly NotModified: 304; /** RFC 7231, 6.4.5 */ readonly UseProxy: 305; /** RFC 7231, 6.4.7 */ readonly TemporaryRedirect: 307; /** RFC 7538, 3 */ readonly PermanentRedirect: 308; /** RFC 7231, 6.5.1 */ readonly BadRequest: 400; /** RFC 7235, 3.1 */ readonly Unauthorized: 401; /** RFC 7231, 6.5.2 */ readonly PaymentRequired: 402; /** RFC 7231, 6.5.3 */ readonly Forbidden: 403; /** RFC 7231, 6.5.4 */ readonly NotFound: 404; /** RFC 7231, 6.5.5 */ readonly MethodNotAllowed: 405; /** RFC 7231, 6.5.6 */ readonly NotAcceptable: 406; /** RFC 7235, 3.2 */ readonly ProxyAuthRequired: 407; /** RFC 7231, 6.5.7 */ readonly RequestTimeout: 408; /** RFC 7231, 6.5.8 */ readonly Conflict: 409; /** RFC 7231, 6.5.9 */ readonly Gone: 410; /** RFC 7231, 6.5.10 */ readonly LengthRequired: 411; /** RFC 7232, 4.2 */ readonly PreconditionFailed: 412; /** RFC 7231, 6.5.11 */ readonly ContentTooLarge: 413; /** RFC 7231, 6.5.12 */ readonly URITooLong: 414; /** RFC 7231, 6.5.13 */ readonly UnsupportedMediaType: 415; /** RFC 7233, 4.4 */ readonly RangeNotSatisfiable: 416; /** RFC 7231, 6.5.14 */ readonly ExpectationFailed: 417; /** RFC 7168, 2.3.3 */ readonly Teapot: 418; /** RFC 7540, 9.1.2 */ readonly MisdirectedRequest: 421; /** RFC 4918, 11.2 */ readonly UnprocessableEntity: 422; /** RFC 4918, 11.3 */ readonly Locked: 423; /** RFC 4918, 11.4 */ readonly FailedDependency: 424; /** RFC 8470, 5.2 */ readonly TooEarly: 425; /** RFC 7231, 6.5.15 */ readonly UpgradeRequired: 426; /** RFC 6585, 3 */ readonly PreconditionRequired: 428; /** RFC 6585, 4 */ readonly TooManyRequests: 429; /** RFC 6585, 5 */ readonly RequestHeaderFieldsTooLarge: 431; /** RFC 7725, 3 */ readonly UnavailableForLegalReasons: 451; /** RFC 7231, 6.6.1 */ readonly InternalServerError: 500; /** RFC 7231, 6.6.2 */ readonly NotImplemented: 501; /** RFC 7231, 6.6.3 */ readonly BadGateway: 502; /** RFC 7231, 6.6.4 */ readonly ServiceUnavailable: 503; /** RFC 7231, 6.6.5 */ readonly GatewayTimeout: 504; /** RFC 7231, 6.6.6 */ readonly HTTPVersionNotSupported: 505; /** RFC 2295, 8.1 */ readonly VariantAlsoNegotiates: 506; /** RFC 4918, 11.5 */ readonly InsufficientStorage: 507; /** RFC 5842, 7.2 */ readonly LoopDetected: 508; /** RFC 2774, 7 */ readonly NotExtended: 510; /** RFC 6585, 6 */ readonly NetworkAuthenticationRequired: 511; }; export type StatusCode = typeof STATUS_CODE[keyof typeof STATUS_CODE]; /** A record of all the status codes text. */ export declare const STATUS_TEXT: { readonly 202: "Accepted"; readonly 208: "Already Reported"; readonly 502: "Bad Gateway"; readonly 400: "Bad Request"; readonly 409: "Conflict"; readonly 100: "Continue"; readonly 201: "Created"; readonly 103: "Early Hints"; readonly 417: "Expectation Failed"; readonly 424: "Failed Dependency"; readonly 403: "Forbidden"; readonly 302: "Found"; readonly 504: "Gateway Timeout"; readonly 410: "Gone"; readonly 505: "HTTP Version Not Supported"; readonly 226: "IM Used"; readonly 507: "Insufficient Storage"; readonly 500: "Internal Server Error"; readonly 411: "Length Required"; readonly 423: "Locked"; readonly 508: "Loop Detected"; readonly 405: "Method Not Allowed"; readonly 421: "Misdirected Request"; readonly 301: "Moved Permanently"; readonly 207: "Multi Status"; readonly 300: "Multiple Choices"; readonly 511: "Network Authentication Required"; readonly 204: "No Content"; readonly 203: "Non Authoritative Info"; readonly 406: "Not Acceptable"; readonly 510: "Not Extended"; readonly 404: "Not Found"; readonly 501: "Not Implemented"; readonly 304: "Not Modified"; readonly 200: "OK"; readonly 206: "Partial Content"; readonly 402: "Payment Required"; readonly 308: "Permanent Redirect"; readonly 412: "Precondition Failed"; readonly 428: "Precondition Required"; readonly 102: "Processing"; readonly 407: "Proxy Auth Required"; readonly 413: "Content Too Large"; readonly 431: "Request Header Fields Too Large"; readonly 408: "Request Timeout"; readonly 414: "URI Too Long"; readonly 416: "Range Not Satisfiable"; readonly 205: "Reset Content"; readonly 303: "See Other"; readonly 503: "Service Unavailable"; readonly 101: "Switching Protocols"; readonly 418: "I'm a teapot"; readonly 307: "Temporary Redirect"; readonly 425: "Too Early"; readonly 429: "Too Many Requests"; readonly 401: "Unauthorized"; readonly 451: "Unavailable For Legal Reasons"; readonly 422: "Unprocessable Entity"; readonly 415: "Unsupported Media Type"; readonly 426: "Upgrade Required"; readonly 305: "Use Proxy"; readonly 506: "Variant Also Negotiates"; }; export type StatusText = typeof STATUS_TEXT[keyof typeof STATUS_TEXT]; /** An HTTP status that is a informational (1XX). */ export type InformationalStatus = typeof STATUS_CODE.Continue | typeof STATUS_CODE.SwitchingProtocols | typeof STATUS_CODE.Processing | typeof STATUS_CODE.EarlyHints; /** An HTTP status that is a success (2XX). */ export type SuccessfulStatus = typeof STATUS_CODE.OK | typeof STATUS_CODE.Created | typeof STATUS_CODE.Accepted | typeof STATUS_CODE.NonAuthoritativeInfo | typeof STATUS_CODE.NoContent | typeof STATUS_CODE.ResetContent | typeof STATUS_CODE.PartialContent | typeof STATUS_CODE.MultiStatus | typeof STATUS_CODE.AlreadyReported | typeof STATUS_CODE.IMUsed; /** An HTTP status that is a redirect (3XX). */ export type RedirectStatus = typeof STATUS_CODE.MultipleChoices | typeof STATUS_CODE.MovedPermanently | typeof STATUS_CODE.Found | typeof STATUS_CODE.SeeOther | typeof STATUS_CODE.UseProxy | typeof STATUS_CODE.TemporaryRedirect | typeof STATUS_CODE.PermanentRedirect; /** An HTTP status that is a client error (4XX). */ export type ClientErrorStatus = typeof STATUS_CODE.BadRequest | typeof STATUS_CODE.Unauthorized | typeof STATUS_CODE.PaymentRequired | typeof STATUS_CODE.Forbidden | typeof STATUS_CODE.NotFound | typeof STATUS_CODE.MethodNotAllowed | typeof STATUS_CODE.NotAcceptable | typeof STATUS_CODE.ProxyAuthRequired | typeof STATUS_CODE.RequestTimeout | typeof STATUS_CODE.Conflict | typeof STATUS_CODE.Gone | typeof STATUS_CODE.LengthRequired | typeof STATUS_CODE.PreconditionFailed | typeof STATUS_CODE.ContentTooLarge | typeof STATUS_CODE.URITooLong | typeof STATUS_CODE.UnsupportedMediaType | typeof STATUS_CODE.RangeNotSatisfiable | typeof STATUS_CODE.ExpectationFailed | typeof STATUS_CODE.Teapot | typeof STATUS_CODE.MisdirectedRequest | typeof STATUS_CODE.UnprocessableEntity | typeof STATUS_CODE.Locked | typeof STATUS_CODE.FailedDependency | typeof STATUS_CODE.UpgradeRequired | typeof STATUS_CODE.PreconditionRequired | typeof STATUS_CODE.TooManyRequests | typeof STATUS_CODE.RequestHeaderFieldsTooLarge | typeof STATUS_CODE.UnavailableForLegalReasons; /** An HTTP status that is a server error (5XX). */ export type ServerErrorStatus = typeof STATUS_CODE.InternalServerError | typeof STATUS_CODE.NotImplemented | typeof STATUS_CODE.BadGateway | typeof STATUS_CODE.ServiceUnavailable | typeof STATUS_CODE.GatewayTimeout | typeof STATUS_CODE.HTTPVersionNotSupported | typeof STATUS_CODE.VariantAlsoNegotiates | typeof STATUS_CODE.InsufficientStorage | typeof STATUS_CODE.LoopDetected | typeof STATUS_CODE.NotExtended | typeof STATUS_CODE.NetworkAuthenticationRequired; /** An HTTP status that is an error (4XX and 5XX). */ export type ErrorStatus = ClientErrorStatus | ServerErrorStatus; export declare function isStatus(status: number): status is StatusCode; /** A type guard that determines if the status code is informational. */ export declare function isInformationalStatus(status: number): status is InformationalStatus; /** A type guard that determines if the status code is successful. */ export declare function isSuccessfulStatus(status: number): status is SuccessfulStatus; /** A type guard that determines if the status code is a redirection. */ export declare function isRedirectStatus(status: number): status is RedirectStatus; /** A type guard that determines if the status code is a client error. */ export declare function isClientErrorStatus(status: number): status is ClientErrorStatus; /** A type guard that determines if the status code is a server error. */ export declare function isServerErrorStatus(status: number): status is ServerErrorStatus; /** A type guard that determines if the status code is an error. */ export declare function isErrorStatus(status: number): status is ErrorStatus;