<div align="center">
<br>
<br>
<img width="360" src="media/logo.svg" alt="Got">
<br>
<br>
<br>
<p align="center">Huge thanks to <a href="https://moxy.studio"><img src="https://sindresorhus.com/assets/thanks/moxy-logo.svg" valign="middle" width="150"></a> for sponsoring Sindre Sorhus!
</p>
<p align="center"><sup>(they love Got too!)</sup></p>
<br>
<br>
</div>
> Human-friendly and powerful HTTP request library for Node.js
[![Build Status: Linux](https://travis-ci.com/sindresorhus/got.svg?branch=master)](https://travis-ci.com/github/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)
[![Install size](https://packagephobia.now.sh/badge?p=got)](https://packagephobia.now.sh/result?p=got)
[Moving from Request?](documentation/migration-guides.md) [*(Note that Request is unmaintained)*](https://github.com/request/request/issues/3142)
[See how Got compares to other HTTP libraries](#comparison)
For browser usage, we recommend [Ky](https://github.com/sindresorhus/ky) by the same people.
## Highlights
- [Promise API](#api)
- [Stream API](#streams)
- [Pagination API](#pagination)
- [HTTP2 support](#http2)
- [Request cancelation](#aborting-the-request)
- [RFC compliant caching](#cache-adapters)
- [Follows redirects](#followredirect)
- [Retries on failure](#retry)
- [Progress events](#onuploadprogress-progress)
- [Handles gzip/deflate/brotli](#decompress)
- [Timeout handling](#timeout)
- [Errors with metadata](#errors)
- [JSON mode](#json-mode)
- [WHATWG URL support](#url)
- [HTTPS API](#advanced-https-api)
- [Hooks](#hooks)
- [Instances with custom defaults](#instances)
- [Types](#types)
- [Composable](documentation/advanced-creation.md#merging-instances)
- [Plugins](documentation/lets-make-a-plugin.md)
- [Used by 4K+ packages and 1.8M+ repos](https://github.com/sindresorhus/got/network/dependents)
- [Actively maintained](https://github.com/sindresorhus/got/graphs/contributors)
- [Trusted by many companies](#widely-used)
## Install
```
$ npm install got
```
## Usage
###### Promise
```js
const got = require('got');
(async () => {
try {
const response = await got('https://sindresorhus.com');
console.log(response.body);
//=> '<!doctype html> ...'
} catch (error) {
console.log(error.response.body);
//=> 'Internal server error ...'
}
})();
```
###### JSON
```js
const got = require('got');
(async () => {
const {body} = await got.post('https://httpbin.org/anything', {
json: {
hello: 'world'
},
responseType: 'json'
});
console.log(body.data);
//=> {hello: 'world'}
})();
```
See [JSON mode](#json-mode) for more details.
###### Streams
```js
const stream = require('stream');
const {promisify} = require('util');
const fs = require('fs');
const got = require('got');
const pipeline = promisify(stream.pipeline);
(async () => {
await pipeline(
got.stream('https://sindresorhus.com'),
fs.createWriteStream('index.html')
);
// For POST, PUT, PATCH, and DELETE methods, `got.stream` returns a `stream.Writable`.
await pipeline(
fs.createReadStream('index.html'),
got.stream.post('https://sindresorhus.com')
);
})();
```
**Tip:** `from.pipe(to)` doesn't forward errors. Instead, use [`stream.pipeline(from, ..., to, callback)`](https://nodejs.org/api/stream.html#stream_stream_pipeline_streams_callback).
**Note:** While `got.post('https://example.com')` resolves, `got.stream.post('https://example.com')` will hang indefinitely until a body is provided. If there's no body on purpose, remember to `.end()` the stream or set the [`body`](#body) option to an empty string.
### API
It's a `GET` request by default, but can be changed by using different methods or via [`options.method`](#method).
**By default, Got will retry on failure. To disable this option, set [`options.retry`](#retry) to `0`.**
#### got(url?, options?)
Returns a Promise giving a [Response object](#response) or a [Got Stream](#streams-1) if `options.isStream` is set to true.
##### url
Type: `string | object`
The URL to request, as a string, a [`https.request` options object](https://nodejs.org/api/https.html#https_https_request_options_callback), or a [WHATWG `URL`](https://nodejs.org/api/url.html#url_class_url).
Properties from `options` will override properties in the parsed `url`.
If no protocol is specified, it will throw a `TypeError`.
**Note:** The query string is **not** parsed as search params. Example:
```js
got('https://example.com/?query=a b'); //=> https://example.com/?query=a%20b
got('https://example.com/', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b
// The query string is overridden by `searchParams`
got('https://example.com/?query=a b', {searchParams: {query: 'a b'}}); //=> https://example.com/?query=a+b
```
##### options
Type: `object`
Any of the [`https.request`](https://nodejs.org/api/https.html#https_https_request_options_callback) options.
**Note:** Legacy URL support is disabled. `options.path` is supported only for backwards compatibility. Use `options.pathname` and `options.searchParams` instead. `options.auth` has been replaced with `options.username` & `options.password`.
###### method
Type: `string`\
Default: `GET`
The HTTP method used to make the request.
###### prefixUrl
Type: `string | URL`
When specified, `prefixUrl` will be prepended to `url`. The prefix can be any valid URL, either relative or absolute.\
A trailing slash `/` is optional - one will be added automatically.
**Note:** `prefixUrl` will be ignored if the `url` argument is a URL instance.
**Note:** Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion. For example, when the prefix URL is `https://example.com/foo` and the input is `/bar`, there's ambiguity whether the resulting URL would become `https://example.com/foo/bar` or `https://example.com/bar`. The latter is used by browsers.
**Tip:** Useful when used with [`got.extend()`](#custom-endpoints) to create niche-specific Got instances.
**Tip:** You can change `prefixUrl` using hooks as long as the URL still includes the `prefixUrl`. If the URL doesn't include it anymore, it will throw.
```js
const got = require('got');
(async () => {
await got('unicorn', {prefixUrl: 'https://cats.com'});
//=> 'https://cats.com/unicorn'
const instance = got.extend({
prefixUrl: 'https://google.com'
});
await instance('unicorn', {
hooks: {
beforeRequest: [
options => {
options.prefixUrl = 'https://cats.com';
}
]
}
});
//=> 'https://cats.com/unicorn'
})();
```
###### headers
Type: `object`\
Default: `{}`
Request headers.
Existing headers will be overwritten. Headers set to `undefined` will be omitted.
###### isStream
Type: `boolean`\
Default: `false`
Returns a `Stream` instead of a `Promise`. This is equivalent to calling `got.stream(url, options?)`.
###### body
Type: `string | Buffer | stream.Readable` or [`form-data` instance](https://github.com/form-data/form-data)
**Note #1:** The `body` option cannot be used with the `json` or `form` option.
**Note #2:** If you provide this option, `got.stream()` will be read-only.
**Note #3:** If you provide a payload with the `GET` or `HEAD` method, it will throw a `TypeError` unless the method is `GET` and the `allowGetBody` option is set to `true`.
**Note #4:** This option is not enumerable and will not be merged with the instance defaults.
The `content-length` header will be automatically set if `body` is a `string` / `Buffer` / `fs.createReadStream` instance / [`form-data` instance](https://github.com/form-data/form-data), and `content-length` and `transfer-encoding` are not manually set in `options.headers`.
###### json
Type: `object | Array | number | string | boolean | null` *(JSON-serializable values)*
**Note #1:** If you provide thi
没有合适的资源?快使用搜索试试~ 我知道了~
内网无线WiFi文件传输工具
共10559个文件
js:5047个
ts:1702个
map:1276个
需积分: 5 0 下载量 196 浏览量
2023-03-05
20:45:53
上传
评论
收藏 118.42MB ZIP 举报
温馨提示
内网无线WiFi文件传输工具
资源推荐
资源详情
资源评论
收起资源包目录
内网无线WiFi文件传输工具 (10559个子文件)
091e74ea9b7a2a32d2b4dc41b133864ac88b61 102KB
0a89628a54cb3549ca18c38c792f6e4e63e94c 130B
http-server.1 4KB
he.1 3KB
138aa7b08ed5dc9312b583091870cd065c9242 337B
1aa92881f5c60e4cc9341ea587a449e09c7276 414B
1c52525e0e0e1e0fe77e5f0ea3bdf615b950d8 169B
1fdcbb2ef9910f9e56af184ef36acf32d41091 896B
2802697fc6810efe9475a4608c619298f0804f 803B
4060f97e9f75d7832b76d154c62631e9d4e585 171B
58a70aff39b667de07c830f31a2217fecddb90 529B
73d40980ccc7de199dc7955542885da3aeb730 255B
7672521195fd5b52e9feec89db90788818ae49 618B
8e5737a341409816757ffe7a0d5cf2e38b442e 336B
9de29bb2d1d6434b8b29ae775ad8c2e48c5391 15B
_bar 0B
_gitignore 1KB
LICENSE.APACHE2 586B
default_app.asar 107KB
asar 300B
AUTHORS 514B
AUTHORS 203B
AUTHORS 152B
.auto-changelog 113B
ba5143c146fa87cbe7c38f198b8f5991233ba0 350B
.babelrc 36B
gyp.bat 201B
v8_context_snapshot.bin 472KB
snapshot_blob.bin 168KB
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
xz-5.2.3.tar.bz2 1.15MB
benchmark-native.c 613B
nothing.c 0B
win_delay_load_hook.cc 872B
large-pdb-shim.cc 653B
changelog 1KB
index.cjs 60KB
index.cjs 45KB
index.cjs 42KB
index.cjs 10KB
index.cjs 7KB
index.cjs 5KB
index.cjs 1KB
.eslintrc.cjs 207B
electron-osx-sign.cmd 348B
electron-osx-flat.cmd 348B
electron-packager.cmd 347B
electron-forge.cmd 347B
electron-forge-vscode-nix.cmd 341B
electron-rebuild.cmd 337B
node-gyp-build-test.cmd 333B
http-server.cmd 332B
node-gyp-build-optional.cmd 331B
yon.cmd 329B
yarn-or-npm.cmd 329B
node-gyp.cmd 329B
opener.cmd 329B
lzmajs.cmd 327B
node-gyp-build.cmd 326B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
semver.cmd 325B
node-which.cmd 325B
color-support.cmd 325B
semver.cmd 325B
semver.cmd 325B
resolve.cmd 324B
extract-zip.cmd 323B
semver.cmd 322B
semver.cmd 322B
mkdirp.cmd 322B
mkdirp.cmd 322B
semver.cmd 322B
mkdirp.cmd 322B
nopt.cmd 321B
asar.cmd 321B
is-docker.cmd 321B
which.cmd 320B
which.cmd 320B
共 10559 条
- 1
- 2
- 3
- 4
- 5
- 6
- 106
资源评论
Vane.Q
- 粉丝: 32
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功