From 3574e356359e6a619cd68edf5cd36eb85fce5ca3 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 28 Apr 2020 23:14:50 -0600 Subject: [PATCH] v1.6.1: userAgent and docs --- EXTRA.md | 35 +++++++++++++++++++++++++++++++++++ examples/postbin.js | 2 +- index.js | 4 ++-- package.json | 2 +- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 EXTRA.md diff --git a/EXTRA.md b/EXTRA.md new file mode 100644 index 0000000..babf071 --- /dev/null +++ b/EXTRA.md @@ -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 } +}); +``` diff --git a/examples/postbin.js b/examples/postbin.js index c5245eb..dacabae 100644 --- a/examples/postbin.js +++ b/examples/postbin.js @@ -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); diff --git a/index.js b/index.js index ca2654e..ec8f9c6 100644 --- a/index.js +++ b/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'); diff --git a/package.json b/package.json index dc7b9f1..7b6f85a 100644 --- a/package.json +++ b/package.json @@ -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": [