@poppanator/http-constants
Version:
This package contains various HTTP constants: http status codes and texts, HTTP header names and HTTP methods, and a few related utility function.
1 lines • 18.5 kB
Source Map (JSON)
{"version":3,"file":"codes-ed46191f.cjs","sources":["../src/codes.ts"],"sourcesContent":["// -------------------------------------------------------------------------- //\n// //\n// Informational //\n// //\n// -------------------------------------------------------------------------- //\n\n/**\n * This interim response indicates that the client should continue the request\n * or ignore the response if the request is already finished.\n */\nexport const Continue = 100\n\n/**\n * This code is sent in response to an\n * [Upgrade](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade)\n * request header from the client and indicates the protocol the server is\n * switching to.\n */\nexport const SwitchingProtocol = 101\n\n/**\n * This code indicates that the server has received and is processing the\n * request, but no response is available yet.\n *\n * @note WebDAV\n */\nexport const Processing = 102\n\n/**\n * This status code is primarily intended to be used with the\n * [Link](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link)\n * header, letting the user agent start preloading resources while the server\n * prepares a response.\n */\nexport const EarlyHints = 103\n\n// -------------------------------------------------------------------------- //\n// //\n// Successful //\n// //\n// -------------------------------------------------------------------------- //\n\n/**\n * The request succeeded. The result meaning of \"success\" depends on the HTTP\n * method:\n *\n * - `GET`: The resource has been fetched and transmitted in the message body.\n * - `HEAD`: The representation headers are included in the response without\n * any message body.\n * - `PUT` or `POST`: The resource describing the result of the action is\n * transmitted in the message body.\n * - `TRACE`: The message body contains the request message as received by\n * the server.\n */\nexport const Ok = 200\n\n/**\n * The request succeeded, and a new resource was created as a result. This is\n * typically the response sent after `POST` requests, or some `PUT` requests.\n */\nexport const Created = 201\n\n/**\n * The request has been received but not yet acted upon. It is noncommittal,\n * since there is no way in HTTP to later send an asynchronous response\n * indicating the outcome of the request. It is intended for cases where another\n * process or server handles the request, or for batch processing.\n */\nexport const Accepted = 202\n\n/**\n * This response code means the returned metadata is not exactly the same as is\n * available from the origin server, but is collected from a local or a\n * third-party copy. This is mostly used for mirrors or backups of another\n * resource. Except for that specific case, the `200 OK` response is preferred\n * to this status.\n */\nexport const NonAuthoritativeInformation = 203\n\n/**\n * There is no content to send for this request, but the headers may be useful.\n * The user agent may update its cached headers for this resource with the new\n * ones.\n */\nexport const NoContent = 204\n\n/**\n * Tells the user agent to reset the document which sent this request.\n */\nexport const ResetContent = 205\n\n/**\n * This response code is used when the\n * [Range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range)\n * header is sent from the client to request only part of a resource.\n */\nexport const PartialContent = 206\n\n/**\n * Conveys information about multiple resources, for situations where multiple\n * status codes might be appropriate.\n *\n * @note WebDAV\n */\nexport const MultiStatus = 207\n\n/**\n * Used inside a `<dav:propstat>` response element to avoid repeatedly\n * enumerating the internal members of multiple bindings to the same collection.\n *\n * @note WebDAV\n */\nexport const AlreadyReported = 208\n\n/**\n * The server has fulfilled a `GET` request for the resource, and the response\n * is a representation of the result of one or more instance-manipulations\n * applied to the current instance.\n *\n * @note [HTTP Delta encoding](https://datatracker.ietf.org/doc/html/rfc3229)\n */\nexport const ImUsed = 226\n\n// -------------------------------------------------------------------------- //\n// //\n// Redirects //\n// //\n// -------------------------------------------------------------------------- //\n\n/**\n * The request has more than one possible response. The user agent or user\n * should choose one of them. (There is no standardized way of choosing one of\n * the responses, but HTML links to the possibilities are recommended so the\n * user can pick.)\n */\nexport const MultipleChoices = 300\n\n/**\n * The URL of the requested resource has been changed permanently. The new URL\n * is given in the response.\n */\nexport const MovedPermanently = 301\n\n/**\n * This response code means that the URI of requested resource has been changed\n * temporarily. Further changes in the URI might be made in the future.\n * Therefore, this same URI should be used by the client in future requests.\n */\nexport const Found = 302\n\n/**\n * The server sent this response to direct the client to get the requested\n * resource at another URI with a `GET` request.\n */\nexport const SeeOther = 303\n\n/**\n * This is used for caching purposes. It tells the client that the response has\n * not been modified, so the client can continue to use the same cached version\n * of the response.\n */\nexport const NotModified = 304\n\n/**\n * Defined in a previous version of the HTTP specification to indicate that a\n * requested response must be accessed by a proxy. It has been deprecated due\n * to security concerns regarding in-band configuration of a proxy.\n *\n * @deprecated\n */\nexport const UseProxy = 305\n\n/**\n * This response code is no longer used; it is just reserved. It was used in a\n * previous version of the HTTP/1.1 specification.\n *\n * @deprecated\n */\nexport const SwitchProxy = 306\n\n/**\n * The server sends this response to direct the client to get the requested\n * resource at another URI with same method that was used in the prior request.\n * This has the same semantics as the `302 Found` HTTP response code, with the\n * exception that the user agent must not change the HTTP method used: if a\n * `POST` was used in the first request, a `POST` must be used in the second\n * request.\n */\nexport const TemporaryRedirect = 307\n\n/**\n * This means that the resource is now permanently located at another URI,\n * specified by the Location: HTTP Response header. This has the same semantics\n * as the `301 Moved Permanently` HTTP response code, with the exception that\n * the user agent must not change the HTTP method used: if a `POST` was used in\n * the first request, a `POST` must be used in the second request.\n */\nexport const PermanentRedirect = 308\n\n// -------------------------------------------------------------------------- //\n// //\n// Client errors //\n// //\n// -------------------------------------------------------------------------- //\n\n/**\n * The server cannot or will not process the request due to something that is\n * perceived to be a client error (e.g., malformed request syntax, invalid\n * request message framing, or deceptive request routing).\n */\nexport const BadRequest = 400\n\n/**\n * Although the HTTP standard specifies \"unauthorized\", semantically this\n * response means \"unauthenticated\". That is, the client must authenticate\n * itself to get the requested response.\n */\nexport const Unauthorized = 401\n\n/**\n * This response code is reserved for future use. The initial aim for creating\n * this code was using it for digital payment systems, however this status code\n * is used very rarely and no standard convention exists.\n */\nexport const PaymentRequired = 402\n\n/**\n * The client does not have access rights to the content; that is, it is\n * unauthorized, so the server is refusing to give the requested resource.\n * Unlike `401 Unauthorized`, the client's identity is known to the server.\n */\nexport const Forbidden = 403\n\n/**\n * The server can not find the requested resource. In the browser, this means\n * the URL is not recognized. In an API, this can also mean that the endpoint\n * is valid but the resource itself does not exist.\n *\n * Servers may also send this response instead of `403 Forbidden` to hide the\n * existence of a resource from an unauthorized client.\n *\n * This response code is probably the most well known due to its frequent\n * occurrence on the web.\n */\nexport const NotFound = 404\n\n/**\n * The request method is known by the server but is not supported by the target\n * resource. For example, an API may not allow calling `DELETE` to remove a\n * resource.\n */\nexport const MethodNotAllowed = 405\n\n/**\n * This response is sent when the web server, after performing\n * [server-driven content negotiation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation#server-driven_negotiation),\n * doesn't find any content that conforms to the criteria given by the user\n * agent.\n */\nexport const NotAcceptable = 406\n\n/**\n * This is similar to `401 Unauthorized` but authentication is needed to be done\n * by a proxy.\n */\nexport const ProxyAuthenticationRequired = 407\n\n/**\n * This response is sent on an idle connection by some servers, even without any\n * previous request by the client. It means that the server would like to shut\n * down this unused connection.\n *\n * This response is used much more since some browsers, like Chrome,\n * Firefox 27+, or IE9, use HTTP pre-connection mechanisms to speed up surfing.\n *\n * Also note that some servers merely shut down the connection without sending\n * this message.\n */\nexport const RequestTimeout = 408\n\n/**\n * This response is sent when a request conflicts with the current state of\n * the server.\n */\nexport const Conflict = 409\n\n/**\n * This response is sent when the requested content has been permanently deleted\n * from server, with no forwarding address. Clients are expected to remove their\n * caches and links to the resource. The HTTP specification intends this status\n * code to be used for \"limited-time, promotional services\".\n *\n * APIs should not feel compelled to indicate resources that have been deleted\n * with this status code.\n */\nexport const Gone = 410\n\n/**\n * Server rejected the request because the `Content-Length` header field is not\n * defined and the server requires it.\n */\nexport const LengthRequired = 411\n\n/**\n * The client has indicated preconditions in its headers which the server does\n * not meet.\n */\nexport const PreconditionFailed = 412\n\n/**\n * Request entity is larger than limits defined by server. The server might\n * close the connection or return an `Retry-After` header field.\n */\nexport const PayloadTooLarge = 413\n\n/**\n * The URI requested by the client is longer than the server is willing to\n * interpret.\n */\nexport const UriTooLong = 414\n\n/**\n * The media format of the requested data is not supported by the server, so\n * the server is rejecting the request.\n */\nexport const UnsupportedMediaType = 415\n\n/**\n * The range specified by the `Range` header field in the request cannot be\n * fulfilled. It's possible that the range is outside the size of the target\n * URI's data.\n */\nexport const RangeNotSatisfiable = 416\n\n/**\n * This response code means the expectation indicated by the `Expect` request\n * header field cannot be met by the server.\n */\nexport const ExpectationFailed = 417\n\n/**\n * The server refuses the attempt to brew coffee with a teapot.\n */\nexport const ImAteapot = 418\n\n/**\n * The request was directed at a server that is not able to produce a response.\n * This can be sent by a server that is not configured to produce responses for\n * the combination of scheme and authority that are included in the request URI.\n */\nexport const MisdirectedRequest = 421\n\n/**\n * The request was well-formed but was unable to be followed due to semantic\n * errors.\n *\n * @note WebDAV\n */\nexport const UnprocessableEntity = 422\n\n/**\n * The resource that is being accessed is locked.\n *\n * @note WebDAV\n */\nexport const Locked = 423\n\n/**\n * The request failed due to failure of a previous request.\n *\n * @note WebDAV\n */\nexport const FailedDependency = 424\n\n/**\n * Indicates that the server is unwilling to risk processing a request that\n * might be replayed.\n *\n * @deprecated\n */\nexport const TooEarly = 425\n\n/**\n * The server refuses to perform the request using the current protocol but\n * might be willing to do so after the client upgrades to a different protocol.\n *\n * The server sends an [`Upgrade`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Upgrade)\n * header in a `426` response to indicate the required protocol(s).\n */\nexport const UpgradeRequired = 426\n\n/**\n * The origin server requires the request to be conditional. This response is\n * intended to prevent the 'lost update' problem, where a client `GET`s a\n * resource's state, modifies it and PUTs it back to the server, when meanwhile\n * a third party has modified the state on the server, leading to a conflict.\n */\nexport const PreconditionRequired = 428\n\n/**\n * The user has sent too many requests in a given amount of time\n * (\"rate limiting\").\n */\nexport const TooManyRequests = 429\n\n/**\n * The server is unwilling to process the request because its header fields are\n * too large. The request may be resubmitted after reducing the size of the\n * request header fields.\n */\nexport const RequestHeaderFieldsTooLarge = 431\n\n/**\n * The user agent requested a resource that cannot legally be provided, such as\n * a web page censored by a government.\n */\nexport const UnavailableForLegalReasons = 451\n\n// -------------------------------------------------------------------------- //\n// //\n// Server errors //\n// //\n// -------------------------------------------------------------------------- //\n\n/**\n * The server has encountered a situation it does not know how to handle.\n */\nexport const InternalServerError = 500\n\n/**\n * The request method is not supported by the server and cannot be handled.\n * The only methods that servers are required to support (and therefore that\n * must not return this code) are `GET` and `HEAD`.\n */\nexport const NotImplemented = 501\n\n/**\n * This error response means that the server, while working as a gateway to get\n * a response needed to handle the request, got an invalid response.\n */\nexport const BadGateway = 502\n\n/**\n * The server is not ready to handle the request.\n *\n * Common causes are a server that is down for maintenance or that is\n * overloaded. Note that together with this response, a user-friendly page\n * explaining the problem should be sent.\n *\n * This response should be used for temporary conditions and the `Retry-After`\n * HTTP header should, if possible, contain the estimated time before the\n * recovery of the service.\n *\n * The webmaster must also take care about the caching-related headers that are\n * sent along with this response, as these temporary condition responses should\n * usually not be cached.\n */\nexport const ServiceUnavailable = 503\n\n/**\n * This error response is given when the server is acting as a gateway and\n * cannot get a response in time.\n */\nexport const GatewayTimeout = 504\n\n/**\n * The HTTP version used in the request is not supported by the server.\n */\nexport const HttpVersionNotSupported = 505\n\n/**\n * The server has an internal configuration error: the chosen variant resource\n * is configured to engage in transparent content negotiation itself, and is\n * therefore not a proper end point in the negotiation process.\n */\nexport const VariantAlsoNegotiates = 506\n\n/**\n * The method could not be performed on the resource because the server is\n * unable to store the representation needed to successfully complete the\n * request.\n *\n * @note WebDAV\n */\nexport const InsufficientStorage = 507\n\n/**\n * The server detected an infinite loop while processing the request.\n *\n * @note WebDAV\n */\nexport const LoopDetected = 508\n\n/**\n * Further extensions to the request are required for the server to fulfill it.\n */\nexport const NotExtended = 510\n\n/**\n * Indicates that the client needs to authenticate to gain network access.\n */\nexport const NetworkAuthenticationRequired = 511\n"],"names":[],"mappings":"aAUO,qEA0DiB,oBA4CO,eAwUL,eAtOA,aA0EF,aAlRA,YAkDD,eA1BG,sBAgTO,qBAkCD,cA7IP,UAnFJ,mBA2TS,SAxKV,4BA6KmB,cA7Hd,WA9NH,wBA2Wa,wBAzDA,mBA9HL,WAgER,iBA8HM,qBAhPI,uBAmGE,qBAjNF,gBArCL,oBA+BI,kCA8Wc,cAjapB,gCAPkB,kBAsLd,gBA6OF,aA5PH,mBA8LM,gBAjRH,OA3GT,mBA0CY,oBAyNC,oBAzFA,sBA3BE,uBA8GC,yBA0FE,eAnXV,gCA+OiB,wBAmER,gCA8EQ,mBApIb,iBA7LF,aAiEJ,uBA+SU,gBAvRP,sBAhKM,sBA0KA,aAgMT,oBAuBO,iBA1LH,+BAuMc,wBA1DP,yBAjCC,oBAgEL,eAtEL,aArJF,0BAiTa,4DAvZb,4BA4CO,uBAwUL,uBAtOA,qBA0EF,qBAlRA,oBAkDD,uBA1BG,8BAgTO,6BAkCD,sBA7IP,kBAnFJ,2BA2TS,iBAxKV,oCA6KmB,sBA7Hd,mBA9NH,gCA2Wa,gCAzDA,2BA9HL,mBAgER,yBA8HM,6BAhPI,+BAmGE,6BAjNF,wBArCL,4BA+BI,0CA8Wc,sBAjapB,wCAPkB,0BAsLd,wBA6OF,qBA5PH,2BA8LM,wBAjRH,eA3GT,2BA0CY,4BAyNC,4BAzFA,8BA3BE,+BA8GC,iCA0FE,uBAnXV,wCA+OiB,gCAmER,wCA8EQ,2BApIb,yBA7LF,qBAiEJ,+BA+SU,wBAvRP,8BAhKM,8BA0KA,qBAgMT,4BAuBO,yBA1LH,uCAuMc,gCA1DP,iCAjCC,4BAgEL,uBAtEL,qBArJF,kCAiTa"}