UNPKG

@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 3.62 kB
{"version":3,"file":"methods-54cbceb9.cjs","sources":["../src/methods.ts"],"sourcesContent":["/**\n * Standardized HTTP methods (verbs)\n */\nexport type Method =\n | typeof Connect\n | typeof Delete\n | typeof Get\n | typeof Head\n | typeof Options\n | typeof Patch\n | typeof Post\n | typeof Put\n | typeof Trace\n\n/**\n * The HTTP `GET` method requests a representation of the specified resource.\n * Requests using GET should only be used to request data (they shouldn't\n * include data).\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET)\n */\nexport const Get = 'GET'\n\n/**\n * The HTTP `POST` method sends data to the server. The type of the body of the\n * request is indicated by the [Content-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type)\n * header.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST)\n */\nexport const Post = 'POST'\n\n/**\n * The HTTP `CONNECT` method starts two-way communications with the requested\n * resource. It can be used to open a tunnel.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT)\n */\nexport const Connect = 'CONNECT'\n\n/**\n * The HTTP `DELETE` request method deletes the specified resource.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE)\n */\nexport const Delete = 'DELETE'\n\n/**\n * The HTTP `HEAD` method requests the [headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers)\n * that would be returned if the `HEAD` request's URL was instead requested with\n * the HTTP {@link Get `GET`} method.\n *\n * For example, if a URL might produce a large download, a `HEAD` request could\n * read its [Content-Length](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Length)\n * header to check the filesize without actually downloading the file.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD)\n */\nexport const Head = 'HEAD'\n\n/**\n * The HTTP `OPTIONS` method requests permitted communication options for a\n * given URL or server. A client can specify a URL with this method, or an\n * asterisk `(*)` to refer to the entire server.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS)\n */\nexport const Options = 'OPTIONS'\n\n/**\n * The HTTP `PATCH` request method applies partial modifications to a resource.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH)\n */\nexport const Patch = 'PATCH'\n\n/**\n * The HTTP `PUT` request method creates a new resource or replaces a\n * representation of the target resource with the request payload.\n *\n * The difference between `PUT` and {@link Post `POST`} is that `PUT` is\n * idempotent: calling it once or several times successively has the same\n * effect (that is no side effect), whereas successive identical\n * {@link Post `POST`} requests may have additional effects, akin to placing an\n * order several times.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT)\n */\nexport const Put = 'PUT'\n\n/**\n * The HTTP `TRACE` method performs a message loop-back test along the path to\n * the target resource, providing a useful debugging mechanism.\n *\n * [See also](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/TRACE)\n */\nexport const Trace = 'TRACE'\n"],"names":["Post","Connect","Delete","Head","Options","Patch","Trace"],"mappings":"aAqBO,MASMA,EAAO,OAQPC,EAAU,UAOVC,EAAS,SAaTC,EAAO,OASPC,EAAU,UAOVC,EAAQ,QAsBRC,EAAQ,qFA3EF,0CAmEA,oGAnEA,kFAmEA"}