postman-request
Advanced tools
Comparing version 2.88.1-postman.19 to 2.88.1-postman.20
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "2.88.1-postman.19", | ||
"version": "2.88.1-postman.20", | ||
"repository": { | ||
@@ -13,0 +13,0 @@ "type": "git", |
@@ -380,2 +380,17 @@ | ||
### Blacklisting headers | ||
Use `options.blacklistHeaders` option to blacklist the list of headers from requests and redirects. | ||
```js | ||
var options = { | ||
setHost: false, // set false to disable addition of `Host` header | ||
blacklistHeaders: ['connection', 'content-length', 'transfer-encoding'] | ||
} | ||
request.post('http://localhost:3000', options, function(err, res, body) { | ||
// "POST / HTTP/1.1\r\n\r\n" | ||
}); | ||
``` | ||
[back to top](#table-of-contents) | ||
@@ -382,0 +397,0 @@ |
@@ -370,4 +370,5 @@ 'use strict' | ||
self.setHost = false | ||
if (!self.hasHeader('host')) { | ||
// Add `Host` header if not defined already | ||
self.setHost = (self.setHost === undefined || Boolean(self.setHost)) | ||
if (!self.hasHeader('host') && self.setHost) { | ||
var hostHeaderName = self.originalHostHeaderName || 'Host' | ||
@@ -382,3 +383,2 @@ self.setHeader(hostHeaderName, self.uri.host) | ||
} | ||
self.setHost = true | ||
} | ||
@@ -893,2 +893,13 @@ | ||
self.req = self.httpModule.request(reqOptions) | ||
// Remove blacklisted headers from the request instance. | ||
// @note don't check for `hasHeader` because headers like `connection`, | ||
// 'content-length', 'transfer-encoding' etc. are added at the very end | ||
// and `removeHeader` updates the Node.js internal state which makes sure | ||
// these headers are not added. | ||
if (Array.isArray(self.blacklistHeaders) && self.blacklistHeaders.length) { | ||
self.blacklistHeaders.forEach(function (header) { | ||
self.req.removeHeader(header) | ||
}) | ||
} | ||
} catch (err) { | ||
@@ -895,0 +906,0 @@ self.emit('error', err) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
238876
3193
1270