v1.6.1: userAgent and docs

This commit is contained in:
AJ ONeal 2020-04-28 23:14:50 -06:00
parent 508f1ce591
commit 3574e35635
4 changed files with 39 additions and 4 deletions

35
EXTRA.md Normal file
View File

@ -0,0 +1,35 @@
# Extra
There are some niche features of @root/request which are beyond the request.js
compatibility.
## userAgent
There's a default User-Agent string describing the version of @root/request, node.js, and the OS.
Add to the default User-Agent
```js
request({
// ...
userAgent: 'my-package/1.0' // add to agent
});
```
Replace the default User-Agent
```js
request({
// ...
headers: { 'User-Agent': 'replace/0.0' }
});
```
Disable the default User-Agent:
```js
request({
// ...
headers: { 'User-Agent': false }
});
```

View File

@ -5,7 +5,7 @@ request({
url: 'https://postb.in/1588134650162-6019286897499?hello=world' url: 'https://postb.in/1588134650162-6019286897499?hello=world'
//headers: { 'user-agent': false } // remove //headers: { 'user-agent': false } // remove
//headers: { 'user-agent': 'test/1.0' } // overwrite //headers: { 'user-agent': 'test/1.0' } // overwrite
//userAgent: 'test/1.1' // not presently implemented //userAgent: 'test/1.1' // add to the default
}) })
.then(function(resp) { .then(function(resp) {
console.log(resp.body); console.log(resp.body);

View File

@ -582,8 +582,8 @@ module.exports._keys = Object.keys(_defaults).concat([
'form', 'form',
'auth', 'auth',
'formData', 'formData',
'FormData' 'FormData',
//'userAgent' 'userAgent' // non-standard for request.js
]); ]);
module.exports.debug = module.exports.debug =
-1 !== (process.env.NODE_DEBUG || '').split(/\s+/g).indexOf('urequest'); -1 !== (process.env.NODE_DEBUG || '').split(/\s+/g).indexOf('urequest');

View File

@ -1,6 +1,6 @@
{ {
"name": "@root/request", "name": "@root/request",
"version": "1.6.0", "version": "1.6.1",
"description": "A lightweight, zero-dependency drop-in replacement for request", "description": "A lightweight, zero-dependency drop-in replacement for request",
"main": "index.js", "main": "index.js",
"files": [ "files": [