/** * http status text adapted from https://go.dev/src/net/http/status.go * Source: https://github.com/golang/go/blob/master/src/net/http/status.go * Commit: 55590f3a2b89f001bcadf0df6eb2dde62618302b */ /** * HTTP status codes as registered with IANA. * See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml * * Based on Go's http library * * @example * ```ts * import { httpStatus } from 'http-codex' * * const text = httpStatus.text(httpStatus.OK) // 'OK' * ``` * * @example Status codes only (smaller bundle size) * ```ts * import { httpStatus } from 'http-codex/status' * * const status = httpStatus.OK // 200 * ``` */ export declare const httpStatus: { /** RFC 9110, 15.2.1 */ readonly Continue: 100; /** RFC 9110, 15.2.2 */ readonly SwitchingProtocols: 101; /** RFC 2518, 10.1 */ readonly Processing: 102; /** RFC 8297 */ readonly EarlyHints: 103; /** RFC 9110, 15.3.1 */ readonly OK: 200; /** RFC 9110, 15.3.2 */ readonly Created: 201; /** RFC 9110, 15.3.3 */ readonly Accepted: 202; /** RFC 9110, 15.3.4 */ readonly NonAuthoritativeInfo: 203; /** RFC 9110, 15.3.5 */ readonly NoContent: 204; /** RFC 9110, 15.3.6 */ readonly ResetContent: 205; /** RFC 9110, 15.3.7 */ 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 9110, 15.4.1 */ readonly MultipleChoices: 300; /** RFC 9110, 15.4.2 */ readonly MovedPermanently: 301; /** RFC 9110, 15.4.3 */ readonly Found: 302; /** RFC 9110, 15.4.4 */ readonly SeeOther: 303; /** RFC 9110, 15.4.5 */ readonly NotModified: 304; /** RFC 9110, 15.4.6 */ readonly UseProxy: 305; /** RFC 9110, 15.4.7 (Unused) */ readonly _: 306; /** RFC 9110, 15.4.8 */ readonly TemporaryRedirect: 307; /** RFC 9110, 15.4.9 */ readonly PermanentRedirect: 308; /** RFC 9110, 15.5.1 */ readonly BadRequest: 400; /** RFC 9110, 15.5.2 */ readonly Unauthorized: 401; /** RFC 9110, 15.5.3 */ readonly PaymentRequired: 402; /** RFC 9110, 15.5.4 */ readonly Forbidden: 403; /** RFC 9110, 15.5.5 */ readonly NotFound: 404; /** RFC 9110, 15.5.6 */ readonly MethodNotAllowed: 405; /** RFC 9110, 15.5.7 */ readonly NotAcceptable: 406; /** RFC 9110, 15.5.8 */ readonly ProxyAuthRequired: 407; /** RFC 9110, 15.5.9 */ readonly RequestTimeout: 408; /** RFC 9110, 15.5.10 */ readonly Conflict: 409; /** RFC 9110, 15.5.11 */ readonly Gone: 410; /** RFC 9110, 15.5.12 */ readonly LengthRequired: 411; /** RFC 9110, 15.5.13 */ readonly PreconditionFailed: 412; /** RFC 9110, 15.5.14 */ readonly RequestEntityTooLarge: 413; /** RFC 9110, 15.5.15 */ readonly RequestURITooLong: 414; /** RFC 9110, 15.5.16 */ readonly UnsupportedMediaType: 415; /** RFC 9110, 15.5.17 */ readonly RequestedRangeNotSatisfiable: 416; /** RFC 9110, 15.5.18 */ readonly ExpectationFailed: 417; /** RFC 9110, 15.5.19 (Unused) */ readonly Teapot: 418; /** RFC 9110, 15.5.20 */ readonly MisdirectedRequest: 421; /** RFC 9110, 15.5.21 */ 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 9110, 15.5.22 */ 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 9110, 15.6.1 */ readonly InternalServerError: 500; /** RFC 9110, 15.6.2 */ readonly NotImplemented: 501; /** RFC 9110, 15.6.3 */ readonly BadGateway: 502; /** RFC 9110, 15.6.4 */ readonly ServiceUnavailable: 503; /** RFC 9110, 15.6.5 */ readonly GatewayTimeout: 504; /** RFC 9110, 15.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 HttpStatusCodeName = keyof typeof httpStatus; export type HttpStatusCode = (typeof httpStatus)[HttpStatusCodeName]; /** * Returns whether the status code should have a null http body. * Currently includes: * * ```ts * httpStatus.SwitchingProtocols // 101 * httpStatus.NoContent // 204 * httpStatus.ResetContent // 205 * httpStatus.NotModified // 304 * ``` * * @example Return null body when needed * * ```ts * import { httpStatus, isNullBodyStatus } from 'http-codex' * * const res = await fetch(url) // Might be 204, 304, etc. * return new Response(isNullBodyStatus(res.status) ? null : res.body, { * // Useful for when we need to customize response headers/init/etc. * }) * ``` */ export declare function isNullBodyStatus(status: HttpStatusCode | (number & {})): boolean; /** * List of null body statuses: * * ```ts * 101 // httpStatus.SwitchingProtocols * 204 // httpStatus.NoContent * 205 // httpStatus.ResetContent * 304 // httpStatus.NotModified * ``` */ export declare const nullBodyStatuses: [101, 204, 205, 304]; //# sourceMappingURL=status.d.ts.map