v1.6.1: userAgent and docs
This commit is contained in:
parent
508f1ce591
commit
3574e35635
|
@ -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 }
|
||||
});
|
||||
```
|
|
@ -5,7 +5,7 @@ request({
|
|||
url: 'https://postb.in/1588134650162-6019286897499?hello=world'
|
||||
//headers: { 'user-agent': false } // remove
|
||||
//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) {
|
||||
console.log(resp.body);
|
||||
|
|
4
index.js
4
index.js
|
@ -582,8 +582,8 @@ module.exports._keys = Object.keys(_defaults).concat([
|
|||
'form',
|
||||
'auth',
|
||||
'formData',
|
||||
'FormData'
|
||||
//'userAgent'
|
||||
'FormData',
|
||||
'userAgent' // non-standard for request.js
|
||||
]);
|
||||
module.exports.debug =
|
||||
-1 !== (process.env.NODE_DEBUG || '').split(/\s+/g).indexOf('urequest');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@root/request",
|
||||
"version": "1.6.0",
|
||||
"version": "1.6.1",
|
||||
"description": "A lightweight, zero-dependency drop-in replacement for request",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
|
|
Loading…
Reference in New Issue