UNPKG

@zkochan/pnpm

Version:

Fast, disk space efficient package manager

163 lines (162 loc) 25 kB
{ "_args": [ [ { "raw": "got@^8.0.1", "scope": null, "escapedName": "got", "name": "got", "rawSpec": "^8.0.1", "spec": ">=8.0.1 <9.0.0", "type": "range" }, "/home/zkochan/src/pnpm/packages/pnpm/node_modules/@pnpm/git-resolver" ] ], "_from": "got@^8.0.1", "_hasShrinkwrap": false, "_id": "got@8.3.2", "_location": "/got", "_nodeVersion": "8.11.2", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/got_8.3.2_1530608473068_0.7461942716317538" }, "_npmUser": { "name": "sindresorhus", "email": "sindresorhus@gmail.com" }, "_npmVersion": "5.6.0", "_phantomChildren": {}, "_requested": { "raw": "got@^8.0.1", "scope": null, "escapedName": "got", "name": "got", "rawSpec": "^8.0.1", "spec": ">=8.0.1 <9.0.0", "type": "range" }, "_requiredBy": [ "/@pnpm/git-resolver", "/@pnpm/server" ], "_resolved": "https://registry.npmjs.org/got/-/got-8.3.2.tgz", "_shasum": "1d23f64390e97f776cac52e5b936e5f514d2e937", "_shrinkwrap": null, "_spec": "got@^8.0.1", "_where": "/home/zkochan/src/pnpm/packages/pnpm/node_modules/@pnpm/git-resolver", "ava": { "concurrency": 4 }, "browser": { "decompress-response": false, "electron": false }, "bugs": { "url": "https://github.com/sindresorhus/got/issues" }, "dependencies": { "@sindresorhus/is": "^0.7.0", "cacheable-request": "^2.1.1", "decompress-response": "^3.3.0", "duplexer3": "^0.1.4", "get-stream": "^3.0.0", "into-stream": "^3.1.0", "is-retry-allowed": "^1.1.0", "isurl": "^1.0.0-alpha5", "lowercase-keys": "^1.0.0", "mimic-response": "^1.0.0", "p-cancelable": "^0.4.0", "p-timeout": "^2.0.1", "pify": "^3.0.0", "safe-buffer": "^5.1.1", "timed-out": "^4.0.1", "url-parse-lax": "^3.0.0", "url-to-options": "^1.0.1" }, "description": "Simplified HTTP requests", "devDependencies": { "ava": "^0.25.0", "coveralls": "^3.0.0", "form-data": "^2.1.1", "get-port": "^3.0.0", "nyc": "^11.0.2", "p-event": "^1.3.0", "pem": "^1.4.4", "proxyquire": "^1.8.0", "sinon": "^4.0.0", "slow-stream": "0.0.4", "tempfile": "^2.0.0", "tempy": "^0.2.1", "universal-url": "1.0.0-alpha", "xo": "^0.20.0" }, "directories": {}, "dist": { "integrity": "sha512-qjUJ5U/hawxosMryILofZCkm3C84PLJS/0grRIpjAwu+Lkxxj5cxeCU25BG0/3mDSpXKTyZr8oh8wIgLaH0QCw==", "shasum": "1d23f64390e97f776cac52e5b936e5f514d2e937", "tarball": "https://registry.npmjs.org/got/-/got-8.3.2.tgz", "fileCount": 5, "unpackedSize": 42097, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbOztZCRA9TVsSAnZWagAAkHAP/0wgOosxGWAt+NpUaQNh\n+CccVWx2Kdbym5AvviSF4jzNp0TO+uorMLgE7mUk2fHkryJQjtmTEdSOV0AF\n4rETEIqvYv1kiGTaXYYAylWzWZR/Kh3L9fzMltEhamXKTSGsIVBMiJHEQeEU\nDE9v/iEPa/+WqjKYGypiUMH1BxtrRzoJn/kRqkPjOlgHloHBoEVAO7rz7V9N\nnprEt/4wDp0Hot+LT8caNRDvgjdk3RgHkrkKq3g/hQ662z1QVhZOWsw6ICNR\nXMbn7RhZAJOqO6QTSAVzO7ztaNeQPlDjU18ddTktn5y6N6tMhFju/A3HJ38n\nLaTv8D0ojMlXQaD1LBVvIa5IdGXVwaAi2GznHvjP2R3vB2SVw6GHODxzrO0p\ncQyc8sgN1QPznDAFBHCIZ8UrUqyMSBeJoJCGLn+ImPRUlL/++em96qa8oXDm\nN0eAUys7GVsbL8NrXP4JHyvccvytG+jvAQAzFnj1OHIdPkIy+fbuDX5ZWbjl\nW1hR55MxVBjFda2mj29jnvgtqt7AdFCL+vgEW8HiWQudjUJzbP8wQdtun3Fu\nY173NF4PUIxFDQedZQbPW59dasXdpEUaeEdoCN904cPYd0k6dNyWwBgclnqC\nEmWYzk8N7QsWAiy/BekK0D6tkVrCtZM46vYVqO4uIkT5VNd8ASmfSy54h/2L\nCTCj\r\n=8ZZL\r\n-----END PGP SIGNATURE-----\r\n" }, "engines": { "node": ">=4" }, "files": [ "index.js", "errors.js" ], "gitHead": "ad7b361dcb2490c3864b845b979b756f13f7d89b", "homepage": "https://github.com/sindresorhus/got#readme", "keywords": [ "http", "https", "get", "got", "url", "uri", "request", "util", "utility", "simple", "curl", "wget", "fetch", "net", "network", "electron" ], "license": "MIT", "maintainers": [ { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, { "name": "Vsevolod Strukchinsky", "email": "floatdrop@gmail.com", "url": "github.com/floatdrop" }, { "name": "Alexander Tesfamichael", "email": "alex.tesfamichael@gmail.com", "url": "alextes.me" } ], "name": "got", "optionalDependencies": {}, "readme": "<div align=\"center\">\n\t<br>\n\t<br>\n\t<img width=\"360\" src=\"media/logo.svg\" alt=\"Got\">\n\t<br>\n\t<br>\n\t<br>\n\t<p align=\"center\">Huge thanks to <a href=\"https://moxy.studio\"><img src=\"https://sindresorhus.com/assets/thanks/moxy-logo.svg\" width=\"150\"></a> for sponsoring me!\n\t</p>\n\t<br>\n\t<br>\n</div>\n\n> Simplified HTTP requests\n\n[![Build Status](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got) [![Coverage Status](https://coveralls.io/repos/github/sindresorhus/got/badge.svg?branch=master)](https://coveralls.io/github/sindresorhus/got?branch=master) [![Downloads](https://img.shields.io/npm/dm/got.svg)](https://npmjs.com/got)\n\nA nicer interface to the built-in [`http`](http://nodejs.org/api/http.html) module.\n\nCreated because [`request`](https://github.com/request/request) is bloated *(several megabytes!)*.\n\n\n## Highlights\n\n- [Promise & stream API](#api)\n- [Request cancelation](#aborting-the-request)\n- [RFC compliant caching](#cache-adapters)\n- [Follows redirects](#followredirect)\n- [Retries on network failure](#retries)\n- [Progress events](#onuploadprogress-progress)\n- [Handles gzip/deflate](#decompress)\n- [Timeout handling](#timeout)\n- [Errors with metadata](#errors)\n- [JSON mode](#json)\n- [WHATWG URL support](#url)\n- [Electron support](#useelectronnet)\n\n\n## Install\n\n```\n$ npm install got\n```\n\n<a href=\"https://www.patreon.com/sindresorhus\">\n\t<img src=\"https://c5.patreon.com/external/logo/become_a_patron_button@2x.png\" width=\"160\">\n</a>\n\n\n## Usage\n\n```js\nconst got = require('got');\n\n(async () => {\n\ttry {\n\t\tconst response = await got('sindresorhus.com');\n\t\tconsole.log(response.body);\n\t\t//=> '<!doctype html> ...'\n\t} catch (error) {\n\t\tconsole.log(error.response.body);\n\t\t//=> 'Internal server error ...'\n\t}\n})();\n```\n\n###### Streams\n\n```js\nconst fs = require('fs');\nconst got = require('got');\n\ngot.stream('sindresorhus.com').pipe(fs.createWriteStream('index.html'));\n\n// For POST, PUT, and PATCH methods `got.stream` returns a `stream.Writable`\nfs.createReadStream('index.html').pipe(got.stream.post('sindresorhus.com'));\n```\n\n\n### API\n\nIt's a `GET` request by default, but can be changed by using different methods or in the `options`.\n\n#### got(url, [options])\n\nReturns a Promise for a `response` object with a `body` property, a `url` property with the request URL or the final URL after redirects, and a `requestUrl` property with the original request URL.\n\nThe response object will normally be a [Node.js HTTP response stream](https://nodejs.org/api/http.html#http_class_http_incomingmessage), however if returned from the cache it will be a [responselike object](https://github.com/lukechilds/responselike) which behaves in the same way.\n\nThe response will also have a `fromCache` property set with a boolean value.\n\n##### url\n\nType: `string` `Object`\n\nThe URL to request as simple string, a [`http.request` options](https://nodejs.org/api/http.html#http_http_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).\n\nProperties from `options` will override properties in the parsed `url`.\n\nIf no protocol is specified, it will default to `https`.\n\n##### options\n\nType: `Object`\n\nAny of the [`http.request`](http://nodejs.org/api/http.html#http_http_request_options_callback) options.\n\n###### stream\n\nType: `boolean`<br>\nDefault: `false`\n\nReturns a `Stream` instead of a `Promise`. This is equivalent to calling `got.stream(url, [options])`.\n\n###### body\n\nType: `string` `Buffer` `stream.Readable`\n\n*This is mutually exclusive with stream mode.*\n\nBody that will be sent with a `POST` request.\n\nIf present in `options` and `options.method` is not set, `options.method` will be set to `POST`.\n\nIf `content-length` or `transfer-encoding` is not set in `options.headers` and `body` is a string or buffer, `content-length` will be set to the body length.\n\n###### encoding\n\nType: `string` `null`<br>\nDefault: `'utf8'`\n\n[Encoding](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to be used on `setEncoding` of the response data. If `null`, the body is returned as a [`Buffer`](https://nodejs.org/api/buffer.html) (binary data).\n\n###### form\n\nType: `boolean`<br>\nDefault: `false`\n\n*This is mutually exclusive with stream mode.*\n\nIf set to `true` and `Content-Type` header is not set, it will be set to `application/x-www-form-urlencoded`.\n\n`body` must be a plain object or array and will be stringified.\n\n###### json\n\nType: `boolean`<br>\nDefault: `false`\n\n*This is mutually exclusive with stream mode.*\n\nIf set to `true` and `Content-Type` header is not set, it will be set to `application/json`.\n\nParse response body with `JSON.parse` and set `accept` header to `application/json`. If used in conjunction with the `form` option, the `body` will the stringified as querystring and the response parsed as JSON.\n\n`body` must be a plain object or array and will be stringified.\n\n###### query\n\nType: `string` `Object`<br>\n\nQuery string object that will be added to the request URL. This will override the query string in `url`.\n\n###### timeout\n\nType: `number` `Object`\n\nMilliseconds to wait for the server to end the response before aborting request with `ETIMEDOUT` error.\n\nThis also accepts an object with separate `connect`, `socket`, and `request` fields for connection, socket, and entire request timeouts.\n\n###### retries\n\nType: `number` `Function`<br>\nDefault: `2`\n\nNumber of request retries when network errors happens. Delays between retries counts with function `1000 * Math.pow(2, retry) + Math.random() * 100`, where `retry` is attempt number (starts from 0).\n\nOption accepts `function` with `retry` and `error` arguments. Function must return delay in milliseconds (`0` return value cancels retry).\n\n**Note:** if `retries` is `number`, `ENOTFOUND` and `ENETUNREACH` error will not be retried (see full list in [`is-retry-allowed`](https://github.com/floatdrop/is-retry-allowed/blob/master/index.js#L12) module).\n\n###### followRedirect\n\nType: `boolean`<br>\nDefault: `true`\n\nDefines if redirect responses should be followed automatically.\n\nNote that if a `303` is sent by the server in response to any request type (`POST`, `DELETE`, etc.), got will automatically\nrequest the resource pointed to in the location header via `GET`. This is in accordance with [the spec](https://tools.ietf.org/html/rfc7231#section-6.4.4).\n\n###### decompress\n\nType: `boolean`<br>\nDefault: `true`\n\nDecompress the response automatically. This will set the `accept-encoding` header to `gzip, deflate` unless you set it yourself.\n\nIf this is disabled, a compressed response is returned as a `Buffer`. This may be useful if you want to handle decompression yourself or stream the raw compressed data.\n\n###### cache\n\nType: `Object`<br>\nDefault: `false`\n\n[Cache adapter instance](#cache-adapters) for storing cached data.\n\n###### useElectronNet\n\nType: `boolean`<br>\nDefault: `false`\n\nWhen used in Electron, Got will use [`electron.net`](https://electronjs.org/docs/api/net/) instead of the Node.js `http` module. According to the Electron docs, it should be fully compatible, but it's not entirely. See [#315](https://github.com/sindresorhus/got/issues/315).\n\n###### throwHttpErrors\n\nType: `boolean`<br>\nDefault: `true`\n\nDetermines if a `got.HTTPError` is thrown for error responses (non-2xx status codes).\n\nIf this is disabled, requests that encounter an error status code will be resolved with the `response` instead of throwing. This may be useful if you are checking for resource availability and are expecting error responses.\n\n#### Streams\n\n#### got.stream(url, [options])\n\n`stream` method will return Duplex stream with additional events:\n\n##### .on('request', request)\n\n`request` event to get the request object of the request.\n\n**Tip**: You can use `request` event to abort request:\n\n```js\ngot.stream('github.com')\n\t.on('request', req => setTimeout(() => req.abort(), 50));\n```\n\n##### .on('response', response)\n\n`response` event to get the response object of the final request.\n\n##### .on('redirect', response, nextOptions)\n\n`redirect` event to get the response object of a redirect. The second argument is options for the next request to the redirect location.\n\n##### .on('uploadProgress', progress)\n##### .on('downloadProgress', progress)\n\nProgress events for uploading (sending request) and downloading (receiving response). The `progress` argument is an object like:\n\n```js\n{\n\tpercent: 0.1,\n\ttransferred: 1024,\n\ttotal: 10240\n}\n```\n\nIf it's not possible to retrieve the body size (can happen when streaming), `total` will be `null`.\n\n**Note**: Progress events can also be used with promises.\n\n```js\n(async () => {\n\tconst response = await got('sindresorhus.com')\n\t\t.on('downloadProgress', progress => {\n\t\t\t// Report download progress\n\t\t})\n\t\t.on('uploadProgress', progress => {\n\t\t\t// Report upload progress\n\t\t});\n\n\tconsole.log(response);\n})();\n```\n\n##### .on('error', error, body, response)\n\n`error` event emitted in case of protocol error (like `ENOTFOUND` etc.) or status error (4xx or 5xx). The second argument is the body of the server response in case of status error. The third argument is response object.\n\n#### got.get(url, [options])\n#### got.post(url, [options])\n#### got.put(url, [options])\n#### got.patch(url, [options])\n#### got.head(url, [options])\n#### got.delete(url, [options])\n\nSets `options.method` to the method name and makes a request.\n\n\n## Errors\n\nEach error contains (if available) `statusCode`, `statusMessage`, `host`, `hostname`, `method`, `path`, `protocol` and `url` properties to make debugging easier.\n\nIn Promise mode, the `response` is attached to the error.\n\n#### got.CacheError\n\nWhen a cache method fails, for example if the database goes down, or there's a filesystem error.\n\n#### got.RequestError\n\nWhen a request fails. Contains a `code` property with error class code, like `ECONNREFUSED`.\n\n#### got.ReadError\n\nWhen reading from response stream fails.\n\n#### got.ParseError\n\nWhen `json` option is enabled, server response code is 2xx, and `JSON.parse` fails.\n\n#### got.HTTPError\n\nWhen server response code is not 2xx. Includes `statusCode`, `statusMessage`, and `redirectUrls` properties.\n\n#### got.MaxRedirectsError\n\nWhen server redirects you more than 10 times. Includes a `redirectUrls` property, which is an array of the URLs Got was redirected to before giving up.\n\n#### got.UnsupportedProtocolError\n\nWhen given an unsupported protocol.\n\n#### got.CancelError\n\nWhen the request is aborted with `.cancel()`.\n\n\n## Aborting the request\n\nThe promise returned by Got has a [`.cancel()`](https://github.com/sindresorhus/p-cancelable) method which, when called, aborts the request.\n\n```js\n(async () => {\n\tconst request = got(url, options);\n\n\t\n\n\t// In another part of the code\n\tif (something) {\n\t\trequest.cancel();\n\t}\n\n\t\n\n\ttry {\n\t\tawait request;\n\t} catch (error) {\n\t\tif (request.isCanceled) { // Or `error instanceof got.CancelError`\n\t\t\t// Handle cancelation\n\t\t}\n\n\t\t// Handle other errors\n\t}\n})();\n```\n\n<a name=\"cache-adapters\"></a>\n## Cache\n\nGot implements [RFC 7234](http://httpwg.org/specs/rfc7234.html) compliant HTTP caching which works out of the box in memory or is easily pluggable with a wide range of storage adapters. Fresh cache entries are served directly from cache and stale cache entries are revalidated with `If-None-Match`/`If-Modified-Since` headers. You can read more about the underlying cache behaviour in the `cacheable-request` [documentation](https://github.com/lukechilds/cacheable-request).\n\nYou can use the JavaScript `Map` type as an in memory cache:\n\n```js\nconst got = require('got');\nconst map = new Map();\n\n(async () => {\n\t\tlet response = await got('sindresorhus.com', {cache: map});\n\t\tconsole.log(response.fromCache);\n\t\t//=> false\n\n\t\tresponse = await got('sindresorhus.com', {cache: map});\n\t\tconsole.log(response.fromCache);\n\t\t//=> true\n})();\n```\n\nGot uses [Keyv](https://github.com/lukechilds/keyv) internally to support a wide range of storage adapters. For something more scalable you could use an [official Keyv storage adapter](https://github.com/lukechilds/keyv#official-storage-adapters):\n\n```\n$ npm install @keyv/redis\n```\n\n```js\nconst got = require('got');\nconst KeyvRedis = require('@keyv/redis');\n\nconst redis = new KeyvRedis('redis://user:pass@localhost:6379');\n\ngot('sindresorhus.com', {cache: redis});\n```\n\nGot supports anything that follows the Map API, so it's easy to write your own storage adapter or use a third-party solution.\n\nFor example, the following are all valid storage adapters:\n\n```js\nconst storageAdapter = new Map();\n// or\nconst storageAdapter = require('./my-storage-adapter');\n// or\nconst QuickLRU = require('quick-lru');\nconst storageAdapter = new QuickLRU({maxSize: 1000});\n\ngot('sindresorhus.com', {cache: storageAdapter});\n```\n\nView the [Keyv docs](https://github.com/lukechilds/keyv) for more information on how to use storage adapters.\n\n\n## Proxies\n\nYou can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the `agent` option to work with proxies:\n\n```js\nconst got = require('got');\nconst tunnel = require('tunnel');\n\ngot('sindresorhus.com', {\n\tagent: tunnel.httpOverHttp({\n\t\tproxy: {\n\t\t\thost: 'localhost'\n\t\t}\n\t})\n});\n```\n\nIf you require different agents for different protocols, you can pass a map of agents to the `agent` option. This is necessary because a request to one protocol might redirect to another. In such a scenario, `got` will switch over to the right protocol agent for you.\n\n```js\nconst got = require('got');\nconst HttpAgent = require('agentkeepalive');\nconst HttpsAgent = HttpAgent.HttpsAgent;\n\ngot('sindresorhus.com', {\n\tagent: {\n\t\thttp: new HttpAgent(),\n\t\thttps: new HttpsAgent()\n\t}\n});\n```\n\n\n## Cookies\n\nYou can use the [`cookie`](https://github.com/jshttp/cookie) module to include cookies in a request:\n\n```js\nconst got = require('got');\nconst cookie = require('cookie');\n\ngot('google.com', {\n\theaders: {\n\t\tcookie: cookie.serialize('foo', 'bar')\n\t}\n});\n```\n\n\n## Form data\n\nYou can use the [`form-data`](https://github.com/form-data/form-data) module to create POST request with form data:\n\n```js\nconst fs = require('fs');\nconst got = require('got');\nconst FormData = require('form-data');\nconst form = new FormData();\n\nform.append('my_file', fs.createReadStream('/foo/bar.jpg'));\n\ngot.post('google.com', {\n\tbody: form\n});\n```\n\n\n## OAuth\n\nYou can use the [`oauth-1.0a`](https://github.com/ddo/oauth-1.0a) module to create a signed OAuth request:\n\n```js\nconst got = require('got');\nconst crypto = require('crypto');\nconst OAuth = require('oauth-1.0a');\n\nconst oauth = OAuth({\n\tconsumer: {\n\t\tkey: process.env.CONSUMER_KEY,\n\t\tsecret: process.env.CONSUMER_SECRET\n\t},\n\tsignature_method: 'HMAC-SHA1',\n\thash_function: (baseString, key) => crypto.createHmac('sha1', key).update(baseString).digest('base64')\n});\n\nconst token = {\n\tkey: process.env.ACCESS_TOKEN,\n\tsecret: process.env.ACCESS_TOKEN_SECRET\n};\n\nconst url = 'https://api.twitter.com/1.1/statuses/home_timeline.json';\n\ngot(url, {\n\theaders: oauth.toHeader(oauth.authorize({url, method: 'GET'}, token)),\n\tjson: true\n});\n```\n\n\n## Unix Domain Sockets\n\nRequests can also be sent via [unix domain sockets](http://serverfault.com/questions/124517/whats-the-difference-between-unix-socket-and-tcp-ip-socket). Use the following URL scheme: `PROTOCOL://unix:SOCKET:PATH`.\n\n- `PROTOCOL` - `http` or `https` *(optional)*\n- `SOCKET` - absolute path to a unix domain socket, e.g. `/var/run/docker.sock`\n- `PATH` - request path, e.g. `/v2/keys`\n\n```js\ngot('http://unix:/var/run/docker.sock:/containers/json');\n\n// or without protocol (http by default)\ngot('unix:/var/run/docker.sock:/containers/json');\n```\n\n## AWS\n\nRequests to AWS services need to have their headers signed. This can be accomplished by using the [`aws4`](https://www.npmjs.com/package/aws4) package. This is an example for querying an [\"Elasticsearch Service\"](https://aws.amazon.com/elasticsearch-service/) host with a signed request.\n\n```js\nconst url = require('url');\nconst AWS = require('aws-sdk');\nconst aws4 = require('aws4');\nconst got = require('got');\nconst config = require('./config');\n\n// Reads keys from the environment or `~/.aws/credentials`. Could be a plain object.\nconst awsConfig = new AWS.Config({ region: config.region });\n\nfunction request(uri, options) {\n\tconst awsOpts = {\n\t\tregion: awsConfig.region,\n\t\theaders: {\n\t\t\taccept: 'application/json',\n\t\t\t'content-type': 'application/json'\n\t\t},\n\t\tmethod: 'GET',\n\t\tjson: true\n\t};\n\n\t// We need to parse the URL before passing it to `got` so `aws4` can sign the request\n\tconst opts = Object.assign(url.parse(uri), awsOpts, options);\n\taws4.sign(opts, awsConfig.credentials);\n\n\treturn got(opts);\n}\n\nrequest(`https://${config.host}/production/users/1`);\n\nrequest(`https://${config.host}/production/`, {\n\t// All usual `got` options\n});\n```\n\n\n## Testing\n\nYou can test your requests by using the [`nock`](https://github.com/node-nock/nock) module to mock an endpoint:\n\n```js\nconst got = require('got');\nconst nock = require('nock');\n\nnock('https://sindresorhus.com')\n\t.get('/')\n\t.reply(200, 'Hello world!');\n\n(async () => {\n\tconst response = await got('sindresorhus.com');\n\tconsole.log(response.body);\n\t//=> 'Hello world!'\n})();\n```\n\nIf you need real integration tests you can use [`create-test-server`](https://github.com/lukechilds/create-test-server):\n\n```js\nconst got = require('got');\nconst createTestServer = require('create-test-server');\n\n(async () => {\n\tconst server = await createTestServer();\n\tserver.get('/', 'Hello world!');\n\n\tconst response = await got(server.url);\n\tconsole.log(response.body);\n\t//=> 'Hello world!'\n\n\tawait server.close();\n})();\n```\n\n\n## Tips\n\n### User Agent\n\nIt's a good idea to set the `'user-agent'` header so the provider can more easily see how their resource is used. By default, it's the URL to this repo.\n\n```js\nconst got = require('got');\nconst pkg = require('./package.json');\n\ngot('sindresorhus.com', {\n\theaders: {\n\t\t'user-agent': `my-module/${pkg.version} (https://github.com/username/my-module)`\n\t}\n});\n```\n\n### 304 Responses\n\nBear in mind, if you send an `if-modified-since` header and receive a `304 Not Modified` response, the body will be empty. It's your responsibility to cache and retrieve the body contents.\n\n\n## Related\n\n- [gh-got](https://github.com/sindresorhus/gh-got) - Got convenience wrapper to interact with the GitHub API\n- [gl-got](https://github.com/singapore/gl-got) - Got convenience wrapper to interact with the GitLab API\n- [travis-got](https://github.com/samverschueren/travis-got) - Got convenience wrapper to interact with the Travis API\n- [graphql-got](https://github.com/kevva/graphql-got) - Got convenience wrapper to interact with GraphQL\n- [GotQL](https://github.com/khaosdoctor/gotql) - Got convenience wrapper to interact with GraphQL using JSON-parsed queries instead of strings\n\n\n## Created by\n\n[![Sindre Sorhus](https://github.com/sindresorhus.png?size=100)](https://sindresorhus.com) | [![Vsevolod Strukchinsky](https://github.com/floatdrop.png?size=100)](https://github.com/floatdrop) | [![Alexander Tesfamichael](https://github.com/AlexTes.png?size=100)](https://github.com/AlexTes) | [![Luke Childs](https://github.com/lukechilds.png?size=100)](https://github.com/lukechilds)\n---|---|---|---\n[Sindre Sorhus](https://sindresorhus.com) | [Vsevolod Strukchinsky](https://github.com/floatdrop) | [Alexander Tesfamichael](https://alextes.me) | [Luke Childs](https://github.com/lukechilds)\n\n\n## License\n\nMIT\n", "readmeFilename": "readme.md", "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/got.git" }, "scripts": { "coveralls": "nyc report --reporter=text-lcov | coveralls", "test": "xo && nyc ava" }, "version": "8.3.2" }