@wiajs/request 3.0.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/.github/ISSUE_TEMPLATE.md +0 -56
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -13
- package/.github/stale.yml +0 -19
- package/.swcrc +0 -57
- package/.travis.yml +0 -21
- package/CONTRIBUTING.md +0 -81
- package/biome.json +0 -44
- package/codecov.yml +0 -2
- package/disabled.appveyor.yml +0 -36
- package/examples/README.md +0 -135
- package/gulpfile.js +0 -71
- package/release.sh +0 -45
- package/tests/browser/karma.conf.js +0 -57
- package/tests/browser/ssl/ca.crt +0 -14
- package/tests/browser/ssl/server.crt +0 -14
- package/tests/browser/ssl/server.key +0 -15
- package/tests/browser/start.js +0 -37
- package/tests/browser/test.js +0 -34
- package/tests/fixtures/har.json +0 -158
- package/tests/googledoodle.jpg +0 -0
- package/tests/server.js +0 -142
- package/tests/squid.conf +0 -76
- package/tests/ssl/ca/README.md +0 -8
- package/tests/ssl/ca/ca.cnf +0 -20
- package/tests/ssl/ca/ca.crl +0 -0
- package/tests/ssl/ca/ca.crt +0 -17
- package/tests/ssl/ca/ca.csr +0 -13
- package/tests/ssl/ca/ca.key +0 -18
- package/tests/ssl/ca/ca.srl +0 -1
- package/tests/ssl/ca/client-enc.key +0 -30
- package/tests/ssl/ca/client.cnf +0 -20
- package/tests/ssl/ca/client.crt +0 -20
- package/tests/ssl/ca/client.csr +0 -18
- package/tests/ssl/ca/client.key +0 -27
- package/tests/ssl/ca/gen-all-certs.sh +0 -6
- package/tests/ssl/ca/gen-client.sh +0 -25
- package/tests/ssl/ca/gen-localhost.sh +0 -22
- package/tests/ssl/ca/gen-server.sh +0 -18
- package/tests/ssl/ca/localhost.cnf +0 -20
- package/tests/ssl/ca/localhost.crt +0 -20
- package/tests/ssl/ca/localhost.csr +0 -18
- package/tests/ssl/ca/localhost.js +0 -33
- package/tests/ssl/ca/localhost.key +0 -27
- package/tests/ssl/ca/server.cnf +0 -19
- package/tests/ssl/ca/server.crt +0 -25
- package/tests/ssl/ca/server.csr +0 -29
- package/tests/ssl/ca/server.js +0 -34
- package/tests/ssl/ca/server.key +0 -51
- package/tests/ssl/npm-ca.crt +0 -16
- package/tests/ssl/test.crt +0 -15
- package/tests/ssl/test.key +0 -15
- package/tests/test-agent.js +0 -102
- package/tests/test-agentOptions.js +0 -51
- package/tests/test-api.js +0 -33
- package/tests/test-aws.js +0 -123
- package/tests/test-baseUrl.js +0 -133
- package/tests/test-basic-auth.js +0 -221
- package/tests/test-bearer-auth.js +0 -187
- package/tests/test-body.js +0 -154
- package/tests/test-cookies.js +0 -130
- package/tests/test-defaults.js +0 -340
- package/tests/test-digest-auth.js +0 -232
- package/tests/test-emptyBody.js +0 -56
- package/tests/test-errors.js +0 -108
- package/tests/test-event-forwarding.js +0 -39
- package/tests/test-follow-all-303.js +0 -45
- package/tests/test-follow-all.js +0 -57
- package/tests/test-form-data-error.js +0 -85
- package/tests/test-form-data.js +0 -133
- package/tests/test-form-urlencoded.js +0 -73
- package/tests/test-form.js +0 -101
- package/tests/test-gzip.js +0 -296
- package/tests/test-har.js +0 -175
- package/tests/test-hawk.js +0 -187
- package/tests/test-headers.js +0 -305
- package/tests/test-http-signature.js +0 -110
- package/tests/test-httpModule.js +0 -112
- package/tests/test-https.js +0 -116
- package/tests/test-isUrl.js +0 -120
- package/tests/test-json-request.js +0 -117
- package/tests/test-localAddress.js +0 -49
- package/tests/test-multipart-encoding.js +0 -147
- package/tests/test-multipart.js +0 -129
- package/tests/test-node-debug.js +0 -95
- package/tests/test-oauth.js +0 -721
- package/tests/test-onelineproxy.js +0 -61
- package/tests/test-option-reuse.js +0 -54
- package/tests/test-options-convenience-method.js +0 -52
- package/tests/test-params.js +0 -101
- package/tests/test-piped-redirect.js +0 -55
- package/tests/test-pipes.js +0 -383
- package/tests/test-pool.js +0 -148
- package/tests/test-promise.js +0 -53
- package/tests/test-proxy-connect.js +0 -80
- package/tests/test-proxy.js +0 -304
- package/tests/test-qs.js +0 -135
- package/tests/test-redirect-auth.js +0 -131
- package/tests/test-redirect-complex.js +0 -93
- package/tests/test-redirect.js +0 -449
- package/tests/test-rfc3986.js +0 -106
- package/tests/test-stream.js +0 -36
- package/tests/test-timeout.js +0 -260
- package/tests/test-timing.js +0 -147
- package/tests/test-toJSON.js +0 -45
- package/tests/test-tunnel.js +0 -466
- package/tests/test-unix.js +0 -74
- package/tests/unicycle.jpg +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@wiajs/request",
|
|
3
3
|
"description": "Stream HTTP request client.",
|
|
4
4
|
"keywords": ["http", "simple", "util", "utility"],
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"exports": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"node": ">= 6"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@wiajs/log": "^4.3.
|
|
48
|
+
"@wiajs/log": "^4.3.10",
|
|
49
49
|
"mime-types": "^2.1.35"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
<!---
|
|
2
|
-
BEFORE YOU SUBMIT please read the following:
|
|
3
|
-
|
|
4
|
-
Please search open/closed issues before submitting since someone might have asked the same thing before!
|
|
5
|
-
|
|
6
|
-
If you have a support request or question please submit them to one of this resources:
|
|
7
|
-
|
|
8
|
-
* Stack Overflow: http://stackoverflow.com/questions/tagged/request+node.js using the tags `node.js` & `request`
|
|
9
|
-
* Gitter community: https://gitter.im/request/request?utm_source=newissue
|
|
10
|
-
* Also have a look at the Readme for more information on how to get support:
|
|
11
|
-
https://github.com/request/request/blob/master/README.md
|
|
12
|
-
|
|
13
|
-
Issues on GitHub are only related to problems of request itself and we cannot answer
|
|
14
|
-
support questions here.
|
|
15
|
-
-->
|
|
16
|
-
|
|
17
|
-
### Summary
|
|
18
|
-
<!--- Provide a general summary of the issue in the title above -->
|
|
19
|
-
|
|
20
|
-
### Simplest Example to Reproduce
|
|
21
|
-
<!--- If describing a bug, tell us what request options we can use to reproduce the same bug/behavior -->
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
request({
|
|
25
|
-
method: 'GET',
|
|
26
|
-
url: 'http://example.com', // a public URL that we can hit to reproduce, if possible
|
|
27
|
-
more: { 'options': 'here' }
|
|
28
|
-
},
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Expected Behavior
|
|
32
|
-
<!--- If you're describing a bug, tell us what should happen -->
|
|
33
|
-
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
|
34
|
-
<!--- If request is handling requests/responses incorrectly, please include a link to the spec or documentation that supports that your expected behavior is correct. -->
|
|
35
|
-
|
|
36
|
-
### Current Behavior
|
|
37
|
-
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
|
38
|
-
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
|
39
|
-
|
|
40
|
-
### Possible Solution
|
|
41
|
-
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
|
42
|
-
<!--- or ideas how to implement the addition or change -->
|
|
43
|
-
|
|
44
|
-
### Context
|
|
45
|
-
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
|
46
|
-
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
|
47
|
-
|
|
48
|
-
### Your Environment
|
|
49
|
-
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
|
50
|
-
|
|
51
|
-
| software | version
|
|
52
|
-
| ---------------- | -------
|
|
53
|
-
| request |
|
|
54
|
-
| node |
|
|
55
|
-
| npm |
|
|
56
|
-
| Operating System |
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
## PR Checklist:
|
|
2
|
-
- [ ] I have run `npm test` locally and all tests are passing.
|
|
3
|
-
- [ ] I have added/updated tests for any new behavior.
|
|
4
|
-
<!-- Request is a complex project, there are VERY FEW exceptions
|
|
5
|
-
where a new test is not required for new behavior. -->
|
|
6
|
-
- [ ] If this is a significant change, an issue has already been created where the problem / solution was discussed: [N/A, or add link to issue here]
|
|
7
|
-
<!-- If you'd like to suggest a significant change to request,
|
|
8
|
-
please create an issue to discuss those changes and gather
|
|
9
|
-
feedback BEFORE submitting your PR. -->
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## PR Description
|
|
13
|
-
<!-- Describe Your PR Here! -->
|
package/.github/stale.yml
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Number of days of inactivity before an issue becomes stale
|
|
2
|
-
daysUntilStale: 365
|
|
3
|
-
# Number of days of inactivity before a stale issue is closed
|
|
4
|
-
daysUntilClose: 7
|
|
5
|
-
# Issues with these labels will never be considered stale
|
|
6
|
-
exemptLabels:
|
|
7
|
-
- "Up for consideration"
|
|
8
|
-
- greenkeeper
|
|
9
|
-
- neverstale
|
|
10
|
-
- bug
|
|
11
|
-
# Label to use when marking an issue as stale
|
|
12
|
-
staleLabel: stale
|
|
13
|
-
# Comment to post when marking an issue as stale. Set to `false` to disable
|
|
14
|
-
markComment: >
|
|
15
|
-
This issue has been automatically marked as stale because it has not had
|
|
16
|
-
recent activity. It will be closed if no further activity occurs. Thank you
|
|
17
|
-
for your contributions.
|
|
18
|
-
# Comment to post when closing a stale issue. Set to `false` to disable
|
|
19
|
-
closeComment: false
|
package/.swcrc
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
[{
|
|
2
|
-
"$schema": "https://json.schemastore.org/swcrc",
|
|
3
|
-
"test": "\\.(js|jsx|mjs|cjs)$",
|
|
4
|
-
"exclude": [".*\\.map$"],
|
|
5
|
-
"jsc": {
|
|
6
|
-
"parser": {
|
|
7
|
-
"syntax": "ecmascript", // "typescript"
|
|
8
|
-
"jsx": false,
|
|
9
|
-
"dynamicImport": false,
|
|
10
|
-
"privateMethod": true,
|
|
11
|
-
"functionBind": false,
|
|
12
|
-
"exportDefaultFrom": false,
|
|
13
|
-
"exportNamespaceFrom": false,
|
|
14
|
-
"decorators": true,
|
|
15
|
-
"decoratorsBeforeExport": false,
|
|
16
|
-
"topLevelAwait": false,
|
|
17
|
-
"importMeta": false
|
|
18
|
-
},
|
|
19
|
-
"transform": {
|
|
20
|
-
"decoratorVersion": "2022-03" // "2021-12" (default)
|
|
21
|
-
},
|
|
22
|
-
"target": "es2022", // es5,es6,es2020,es2021,es2022
|
|
23
|
-
"loose": true,
|
|
24
|
-
"externalHelpers": false,
|
|
25
|
-
"keepClassNames": true // 保留原始类名
|
|
26
|
-
},
|
|
27
|
-
"module": {
|
|
28
|
-
"type": "es6" // 输出模块类型 es6 commonjs
|
|
29
|
-
},
|
|
30
|
-
"minify": false, // 压缩代码
|
|
31
|
-
"sourceMaps": false
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"$schema": "https://json.schemastore.org/swcrc",
|
|
35
|
-
"test": "\\.(ts|tsx)$",
|
|
36
|
-
"exclude": [".*\\.map$"],
|
|
37
|
-
"jsc": {
|
|
38
|
-
"parser": {
|
|
39
|
-
"syntax": "typescript",
|
|
40
|
-
"tsx": false,
|
|
41
|
-
"decorators": true,
|
|
42
|
-
"dynamicImport": false
|
|
43
|
-
},
|
|
44
|
-
"transform": {
|
|
45
|
-
"decoratorVersion": "2022-03"
|
|
46
|
-
},
|
|
47
|
-
"target": "es2022", // es5,es6,es2020,es2021,es2022
|
|
48
|
-
"loose": true,
|
|
49
|
-
"externalHelpers": false,
|
|
50
|
-
"keepClassNames": true // 保留原始类名
|
|
51
|
-
},
|
|
52
|
-
"module": {
|
|
53
|
-
"type": "es6" // 输出模块类型 es6 commonjs
|
|
54
|
-
},
|
|
55
|
-
"minify": false, // 压缩代码
|
|
56
|
-
"sourceMaps": false
|
|
57
|
-
}]
|
package/.travis.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
language: node_js
|
|
3
|
-
|
|
4
|
-
node_js:
|
|
5
|
-
- node
|
|
6
|
-
- 10
|
|
7
|
-
- 8
|
|
8
|
-
- 6
|
|
9
|
-
|
|
10
|
-
after_script:
|
|
11
|
-
- npm run test-cov
|
|
12
|
-
- codecov
|
|
13
|
-
- cat ./coverage/lcov.info | coveralls
|
|
14
|
-
|
|
15
|
-
webhooks:
|
|
16
|
-
urls: https://webhooks.gitter.im/e/237280ed4796c19cc626
|
|
17
|
-
on_success: change # options: [always|never|change] default: always
|
|
18
|
-
on_failure: always # options: [always|never|change] default: always
|
|
19
|
-
on_start: false # default: false
|
|
20
|
-
|
|
21
|
-
sudo: false
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Contributing to Request
|
|
3
|
-
|
|
4
|
-
:+1::tada: First off, thanks for taking the time to contribute! :tada::+1:
|
|
5
|
-
|
|
6
|
-
The following is a set of guidelines for contributing to Request and its packages, which are hosted in the [Request Organization](https://github.com/request) on GitHub.
|
|
7
|
-
These are just guidelines, not rules, use your best judgment and feel free to propose changes to this document in a pull request.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## Submitting an Issue
|
|
11
|
-
|
|
12
|
-
1. Provide a small self **sufficient** code example to **reproduce** the issue.
|
|
13
|
-
2. Run your test code using [request-debug](https://github.com/request/request-debug) and copy/paste the results inside the issue.
|
|
14
|
-
3. You should **always** use fenced code blocks when submitting code examples or any other formatted output:
|
|
15
|
-
<pre>
|
|
16
|
-
```js
|
|
17
|
-
put your javascript code here
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
put any other formatted output here,
|
|
22
|
-
like for example the one returned from using request-debug
|
|
23
|
-
```
|
|
24
|
-
</pre>
|
|
25
|
-
|
|
26
|
-
If the problem cannot be reliably reproduced, the issue will be marked as `Not enough info (see CONTRIBUTING.md)`.
|
|
27
|
-
|
|
28
|
-
If the problem is not related to request the issue will be marked as `Help (please use Stackoverflow)`.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## Submitting a Pull Request
|
|
32
|
-
|
|
33
|
-
1. In almost all of the cases your PR **needs tests**. Make sure you have any.
|
|
34
|
-
2. Run `npm test` locally. Fix any errors before pushing to GitHub.
|
|
35
|
-
3. After submitting the PR a build will be triggered on TravisCI. Wait for it to ends and make sure all jobs are passing.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-----------------------------------------
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## Becoming a Contributor
|
|
42
|
-
|
|
43
|
-
Individuals making significant and valuable contributions are given
|
|
44
|
-
commit-access to the project to contribute as they see fit. This project is
|
|
45
|
-
more like an open wiki than a standard guarded open source project.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
## Rules
|
|
49
|
-
|
|
50
|
-
There are a few basic ground-rules for contributors:
|
|
51
|
-
|
|
52
|
-
1. **No `--force` pushes** or modifying the Git history in any way.
|
|
53
|
-
1. **Non-master branches** ought to be used for ongoing work.
|
|
54
|
-
1. **Any** change should be added through Pull Request.
|
|
55
|
-
1. **External API changes and significant modifications** ought to be subject
|
|
56
|
-
to an **internal pull-request** to solicit feedback from other contributors.
|
|
57
|
-
1. Internal pull-requests to solicit feedback are *encouraged* for any other
|
|
58
|
-
non-trivial contribution but left to the discretion of the contributor.
|
|
59
|
-
1. For significant changes wait a full 24 hours before merging so that active
|
|
60
|
-
contributors who are distributed throughout the world have a chance to weigh
|
|
61
|
-
in.
|
|
62
|
-
1. Contributors should attempt to adhere to the prevailing code-style.
|
|
63
|
-
1. Run `npm test` locally before submitting your PR, to catch any easy to miss
|
|
64
|
-
style & testing issues. To diagnose test failures, there are two ways to
|
|
65
|
-
run a single test file:
|
|
66
|
-
- `node_modules/.bin/taper tests/test-file.js` - run using the default
|
|
67
|
-
[`taper`](https://github.com/nylen/taper) test reporter.
|
|
68
|
-
- `node tests/test-file.js` - view the raw
|
|
69
|
-
[tap](https://testanything.org/) output.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
## Releases
|
|
73
|
-
|
|
74
|
-
Declaring formal releases remains the prerogative of the project maintainer.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
## Changes to this arrangement
|
|
78
|
-
|
|
79
|
-
This is an experiment and feedback is welcome! This document may also be
|
|
80
|
-
subject to pull-requests or changes by contributors where you believe you have
|
|
81
|
-
something valuable to add or change.
|
package/biome.json
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
|
|
3
|
-
"organizeImports": {
|
|
4
|
-
"enabled": true
|
|
5
|
-
},
|
|
6
|
-
"vcs": {
|
|
7
|
-
"enabled": true,
|
|
8
|
-
"clientKind": "git",
|
|
9
|
-
"useIgnoreFile": true
|
|
10
|
-
},
|
|
11
|
-
"formatter": {
|
|
12
|
-
"enabled": true,
|
|
13
|
-
"indentStyle": "space",
|
|
14
|
-
"lineEnding": "lf",
|
|
15
|
-
"lineWidth": 120
|
|
16
|
-
},
|
|
17
|
-
"javascript": {
|
|
18
|
-
"formatter": {
|
|
19
|
-
"quoteStyle": "single",
|
|
20
|
-
"quoteProperties": "asNeeded",
|
|
21
|
-
"trailingCommas": "es5",
|
|
22
|
-
"semicolons": "asNeeded",
|
|
23
|
-
"arrowParentheses": "asNeeded",
|
|
24
|
-
"bracketSpacing": false,
|
|
25
|
-
"bracketSameLine": true
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"linter": {
|
|
29
|
-
"enabled": true,
|
|
30
|
-
"rules": {
|
|
31
|
-
"recommended": true,
|
|
32
|
-
"style": {
|
|
33
|
-
"noParameterAssign": "warn"
|
|
34
|
-
},
|
|
35
|
-
"complexity": {
|
|
36
|
-
"noForEach": "warn",
|
|
37
|
-
"noStaticOnlyClass": "warn",
|
|
38
|
-
"noUselessSwitchCase": "error",
|
|
39
|
-
"useFlatMap": "error",
|
|
40
|
-
"noUselessThisAlias": "off"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
package/codecov.yml
DELETED
package/disabled.appveyor.yml
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# http://www.appveyor.com/docs/appveyor-yml
|
|
2
|
-
|
|
3
|
-
# Fix line endings in Windows. (runs before repo cloning)
|
|
4
|
-
init:
|
|
5
|
-
- git config --global core.autocrlf input
|
|
6
|
-
|
|
7
|
-
# Test against these versions of Node.js.
|
|
8
|
-
environment:
|
|
9
|
-
matrix:
|
|
10
|
-
- nodejs_version: "0.10"
|
|
11
|
-
- nodejs_version: "0.8"
|
|
12
|
-
- nodejs_version: "0.11"
|
|
13
|
-
|
|
14
|
-
# Allow failing jobs for bleeding-edge Node.js versions.
|
|
15
|
-
matrix:
|
|
16
|
-
allow_failures:
|
|
17
|
-
- nodejs_version: "0.11"
|
|
18
|
-
|
|
19
|
-
# Install scripts. (runs after repo cloning)
|
|
20
|
-
install:
|
|
21
|
-
# Get the latest stable version of Node 0.STABLE.latest
|
|
22
|
-
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
|
|
23
|
-
# Typical npm stuff.
|
|
24
|
-
- npm install
|
|
25
|
-
|
|
26
|
-
# Post-install test scripts.
|
|
27
|
-
test_script:
|
|
28
|
-
# Output useful info for debugging.
|
|
29
|
-
- ps: "npm test # PowerShell" # Pass comment to PS for easier debugging
|
|
30
|
-
- cmd: npm test
|
|
31
|
-
|
|
32
|
-
# Don't actually build.
|
|
33
|
-
build: off
|
|
34
|
-
|
|
35
|
-
# Set build version format here instead of in the admin panel.
|
|
36
|
-
version: "{build}"
|
package/examples/README.md
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Authentication
|
|
3
|
-
|
|
4
|
-
## OAuth
|
|
5
|
-
|
|
6
|
-
### OAuth1.0 Refresh Token
|
|
7
|
-
|
|
8
|
-
- http://oauth.googlecode.com/svn/spec/ext/session/1.0/drafts/1/spec.html#anchor4
|
|
9
|
-
- https://developer.yahoo.com/oauth/guide/oauth-refreshaccesstoken.html
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
request.post('https://api.login.yahoo.com/oauth/v2/get_token', {
|
|
13
|
-
oauth: {
|
|
14
|
-
consumer_key: '...',
|
|
15
|
-
consumer_secret: '...',
|
|
16
|
-
token: '...',
|
|
17
|
-
token_secret: '...',
|
|
18
|
-
session_handle: '...'
|
|
19
|
-
}
|
|
20
|
-
}, function (err, res, body) {
|
|
21
|
-
var result = require('querystring').parse(body)
|
|
22
|
-
// assert.equal(typeof result, 'object')
|
|
23
|
-
})
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### OAuth2 Refresh Token
|
|
27
|
-
|
|
28
|
-
- https://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-6
|
|
29
|
-
|
|
30
|
-
```js
|
|
31
|
-
request.post('https://accounts.google.com/o/oauth2/token', {
|
|
32
|
-
form: {
|
|
33
|
-
grant_type: 'refresh_token',
|
|
34
|
-
client_id: '...',
|
|
35
|
-
client_secret: '...',
|
|
36
|
-
refresh_token: '...'
|
|
37
|
-
},
|
|
38
|
-
json: true
|
|
39
|
-
}, function (err, res, body) {
|
|
40
|
-
// assert.equal(typeof body, 'object')
|
|
41
|
-
})
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
# Multipart
|
|
45
|
-
|
|
46
|
-
## multipart/form-data
|
|
47
|
-
|
|
48
|
-
### Flickr Image Upload
|
|
49
|
-
|
|
50
|
-
- https://www.flickr.com/services/api/upload.api.html
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
request.post('https://up.flickr.com/services/upload', {
|
|
54
|
-
oauth: {
|
|
55
|
-
consumer_key: '...',
|
|
56
|
-
consumer_secret: '...',
|
|
57
|
-
token: '...',
|
|
58
|
-
token_secret: '...'
|
|
59
|
-
},
|
|
60
|
-
// all meta data should be included here for proper signing
|
|
61
|
-
qs: {
|
|
62
|
-
title: 'My cat is awesome',
|
|
63
|
-
description: 'Sent on ' + new Date(),
|
|
64
|
-
is_public: 1
|
|
65
|
-
},
|
|
66
|
-
// again the same meta data + the actual photo
|
|
67
|
-
formData: {
|
|
68
|
-
title: 'My cat is awesome',
|
|
69
|
-
description: 'Sent on ' + new Date(),
|
|
70
|
-
is_public: 1,
|
|
71
|
-
photo:fs.createReadStream('cat.png')
|
|
72
|
-
},
|
|
73
|
-
json: true
|
|
74
|
-
}, function (err, res, body) {
|
|
75
|
-
// assert.equal(typeof body, 'object')
|
|
76
|
-
})
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
# Streams
|
|
80
|
-
|
|
81
|
-
## `POST` data
|
|
82
|
-
|
|
83
|
-
Use Request as a Writable stream to easily `POST` Readable streams (like files, other HTTP requests, or otherwise).
|
|
84
|
-
|
|
85
|
-
TL;DR: Pipe a Readable Stream onto Request via:
|
|
86
|
-
|
|
87
|
-
```
|
|
88
|
-
READABLE.pipe(request.post(URL));
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
A more detailed example:
|
|
92
|
-
|
|
93
|
-
```js
|
|
94
|
-
var fs = require('fs')
|
|
95
|
-
, path = require('path')
|
|
96
|
-
, http = require('http')
|
|
97
|
-
, request = require('request')
|
|
98
|
-
, TMP_FILE_PATH = path.join(path.sep, 'tmp', 'foo')
|
|
99
|
-
;
|
|
100
|
-
|
|
101
|
-
// write a temporary file:
|
|
102
|
-
fs.writeFileSync(TMP_FILE_PATH, 'foo bar baz quk\n');
|
|
103
|
-
|
|
104
|
-
http.createServer(function(req, res) {
|
|
105
|
-
console.log('the server is receiving data!\n');
|
|
106
|
-
req
|
|
107
|
-
.on('end', res.end.bind(res))
|
|
108
|
-
.pipe(process.stdout)
|
|
109
|
-
;
|
|
110
|
-
}).listen(3000).unref();
|
|
111
|
-
|
|
112
|
-
fs.createReadStream(TMP_FILE_PATH)
|
|
113
|
-
.pipe(request.post('http://127.0.0.1:3000'))
|
|
114
|
-
;
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
# Proxys
|
|
118
|
-
|
|
119
|
-
Run tor on the terminal and try the following. (Needs `socks5-http-client` to connect to tor)
|
|
120
|
-
|
|
121
|
-
```js
|
|
122
|
-
var request = require('../index.js');
|
|
123
|
-
var Agent = require('socks5-http-client/lib/Agent');
|
|
124
|
-
|
|
125
|
-
request.get({
|
|
126
|
-
url: 'http://www.tenreads.io',
|
|
127
|
-
agentClass: Agent,
|
|
128
|
-
agentOptions: {
|
|
129
|
-
socksHost: 'localhost', // Defaults to 'localhost'.
|
|
130
|
-
socksPort: 9050 // Defaults to 1080.
|
|
131
|
-
}
|
|
132
|
-
}, function (err, res) {
|
|
133
|
-
console.log(res.body);
|
|
134
|
-
});
|
|
135
|
-
```
|
package/gulpfile.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
-
import gulp from 'gulp'
|
|
3
|
-
import fs from 'fs-extra'
|
|
4
|
-
import {build} from './script/build.js'
|
|
5
|
-
import configs from './script/config.js'
|
|
6
|
-
|
|
7
|
-
const nodeEnv = process.env.NODE_ENV || 'development'
|
|
8
|
-
const src = './src'
|
|
9
|
-
const out = './dist'
|
|
10
|
-
|
|
11
|
-
console.log(`env:${nodeEnv} src:${src} out:${out}`)
|
|
12
|
-
|
|
13
|
-
if (!fs.existsSync(out)) {
|
|
14
|
-
fs.mkdirSync(out)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 删除已有发布文件,全部重新生成
|
|
19
|
-
* @returns
|
|
20
|
-
*/
|
|
21
|
-
async function clean(cb) {
|
|
22
|
-
// const toRemove = ['*.map'].map(cmd => `rm -rf ${cmd}`);
|
|
23
|
-
// await exec.promise(`cd dist && ${toRemove.join(' && ')}`);
|
|
24
|
-
await fs.emptyDir('./dist/')
|
|
25
|
-
cb && cb()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 同时生成umd、cjs、esm 三种格式输出文件
|
|
30
|
-
*/
|
|
31
|
-
const buildAll = gulp.series(clean, cb => {
|
|
32
|
-
console.log('start build ...')
|
|
33
|
-
build(configs, cb)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 仅生成cjs 格式
|
|
38
|
-
*/
|
|
39
|
-
gulp.task('cjs', cb => {
|
|
40
|
-
console.log('dev cjs...')
|
|
41
|
-
// filter configs
|
|
42
|
-
const cfg = configs.filter(c => c.output.format === 'cjs')
|
|
43
|
-
build(cfg, cb)
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 仅生成 esm 格式
|
|
48
|
-
*/
|
|
49
|
-
gulp.task('esm', cb => {
|
|
50
|
-
console.log('dev esm...')
|
|
51
|
-
// filter configs
|
|
52
|
-
const cfg = configs.filter(c => c.output.format === 'esm')
|
|
53
|
-
build(cfg, cb)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 仅生成 umd 格式
|
|
58
|
-
*/
|
|
59
|
-
gulp.task('umd', cb => {
|
|
60
|
-
console.log('dev umd...')
|
|
61
|
-
// filter configs
|
|
62
|
-
const cfg = configs.filter(c => c.output.format === 'umd')
|
|
63
|
-
build(cfg, cb)
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
gulp.task('watch', () => {
|
|
67
|
-
gulp.watch(`${src}/*.js`, gulp.series([buildAll]))
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
export default buildAll
|
|
71
|
-
export {buildAll as build}
|
package/release.sh
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
if [ -z "`which github-changes`" ]; then
|
|
4
|
-
# specify version because github-changes "is under heavy development. Things
|
|
5
|
-
# may break between releases" until 0.1.0
|
|
6
|
-
echo "First, do: [sudo] npm install -g github-changes@0.0.14"
|
|
7
|
-
exit 1
|
|
8
|
-
fi
|
|
9
|
-
|
|
10
|
-
if [ -d .git/refs/remotes/upstream ]; then
|
|
11
|
-
remote=upstream
|
|
12
|
-
else
|
|
13
|
-
remote=origin
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
|
-
# Increment v2.x.y -> v2.x+1.0
|
|
17
|
-
npm version minor || exit 1
|
|
18
|
-
|
|
19
|
-
# Generate changelog from pull requests
|
|
20
|
-
github-changes -o request -r request \
|
|
21
|
-
--auth --verbose \
|
|
22
|
-
--file CHANGELOG.md \
|
|
23
|
-
--only-pulls --use-commit-body \
|
|
24
|
-
--date-format '(YYYY/MM/DD)' \
|
|
25
|
-
|| exit 1
|
|
26
|
-
|
|
27
|
-
# Since the tag for the new version hasn't been pushed yet, any changes in it
|
|
28
|
-
# will be marked as "upcoming"
|
|
29
|
-
version="$(grep '"version"' package.json | cut -d'"' -f4)"
|
|
30
|
-
sed -i -e "s/^### upcoming/### v$version/" CHANGELOG.md
|
|
31
|
-
|
|
32
|
-
# This may fail if no changelog updates
|
|
33
|
-
# TODO: would this ever actually happen? handle it better?
|
|
34
|
-
git add CHANGELOG.md; git commit -m 'Update changelog'
|
|
35
|
-
|
|
36
|
-
# Publish the new version to npm
|
|
37
|
-
npm publish || exit 1
|
|
38
|
-
|
|
39
|
-
# Increment v2.x.0 -> v2.x.1
|
|
40
|
-
# For rationale, see:
|
|
41
|
-
# https://github.com/request/oauth-sign/issues/10#issuecomment-58917018
|
|
42
|
-
npm version patch || exit 1
|
|
43
|
-
|
|
44
|
-
# Push back to the main repo
|
|
45
|
-
git push $remote master --tags || exit 1
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
var istanbul = require('browserify-istanbul')
|
|
3
|
-
|
|
4
|
-
module.exports = function (config) {
|
|
5
|
-
config.set({
|
|
6
|
-
client: { requestTestUrl: process.argv[4] },
|
|
7
|
-
basePath: '../..',
|
|
8
|
-
frameworks: ['tap', 'browserify'],
|
|
9
|
-
preprocessors: {
|
|
10
|
-
'tests/browser/test.js': ['browserify'],
|
|
11
|
-
'*.js,!(tests)/**/*.js': ['coverage']
|
|
12
|
-
},
|
|
13
|
-
files: [
|
|
14
|
-
'tests/browser/test.js'
|
|
15
|
-
],
|
|
16
|
-
port: 9876,
|
|
17
|
-
|
|
18
|
-
reporters: ['dots', 'coverage'],
|
|
19
|
-
|
|
20
|
-
colors: true,
|
|
21
|
-
|
|
22
|
-
logLevel: config.LOG_ERROR,
|
|
23
|
-
|
|
24
|
-
autoWatch: false,
|
|
25
|
-
|
|
26
|
-
browsers: ['PhantomJS_without_security'],
|
|
27
|
-
|
|
28
|
-
singleRun: true,
|
|
29
|
-
|
|
30
|
-
plugins: [
|
|
31
|
-
'karma-phantomjs-launcher',
|
|
32
|
-
'karma-coverage',
|
|
33
|
-
'karma-browserify',
|
|
34
|
-
'karma-tap'
|
|
35
|
-
],
|
|
36
|
-
browserify: {
|
|
37
|
-
debug: true,
|
|
38
|
-
transform: [istanbul({
|
|
39
|
-
ignore: ['**/node_modules/**', '**/tests/**']
|
|
40
|
-
})]
|
|
41
|
-
},
|
|
42
|
-
coverageReporter: {
|
|
43
|
-
type: 'lcov',
|
|
44
|
-
dir: 'coverage/'
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
// Custom launcher to allowe self signed certs.
|
|
48
|
-
customLaunchers: {
|
|
49
|
-
PhantomJS_without_security: {
|
|
50
|
-
base: 'PhantomJS',
|
|
51
|
-
flags: [
|
|
52
|
-
'--ignore-ssl-errors=true'
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
}
|
package/tests/browser/ssl/ca.crt
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
-----BEGIN CERTIFICATE-----
|
|
2
|
-
MIICKTCCAZICCQDB/6lRlsirjzANBgkqhkiG9w0BAQUFADBZMQswCQYDVQQGEwJB
|
|
3
|
-
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
|
|
4
|
-
cyBQdHkgTHRkMRIwEAYDVQQDEwlsb2NhbGhvc3QwHhcNMTUwMTA3MTcwODM2WhcN
|
|
5
|
-
MjUwMTA0MTcwODM2WjBZMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0
|
|
6
|
-
ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRIwEAYDVQQDEwls
|
|
7
|
-
b2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMba6FQ1VkgW8vWa
|
|
8
|
-
FBxV1VdLhQ5HP0eKZ/CyEGG4r89CzfzC0+V3bnFWGBGF2kSJlVjc7eVSSVio383A
|
|
9
|
-
inq3i+86Mavfy18BwcP4I0NqUSvvcV9yduBLUySklJhOlhhHeFUlycQyxuODbrG9
|
|
10
|
-
QOd411c4eccsbDHq5vSnS7AJh6tVAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAI0H3
|
|
11
|
-
bJIUQgnSGyrSHmjoKm66QLBPvQ1Zd7Zxjlg1uFv6glPOhdkeTQx9XQPT/WDG3qmJ
|
|
12
|
-
BdHvQLDtPS9P8vRaiQW1OCP7dQJkVYCxyFbSQiieuzwBAEGtZcLdZbvcp3PKRGbx
|
|
13
|
-
sIrkzyYdAXE1EZ5z7yLVcpWwTKnBnuRz2D0XOk4=
|
|
14
|
-
-----END CERTIFICATE-----
|