Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-headers-filter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-headers-filter - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

48

index.js

@@ -1,3 +0,1 @@

'use strict';
/**

@@ -11,2 +9,7 @@ * @license

'use strict';
exports.filterHeaders = filterHeaders;
exports.saveHeaders = saveHeaders;
/**

@@ -19,10 +22,7 @@ * Truncate unrequired headers from request

*/
function filterHeaders(incomingMessage, headersList, save) {
save = save || false;
save = Boolean(save);
var headers = incomingMessage.headers;
var regexps = headersList.map(function (headerName) {
return new RegExp(headerName);
});
var regexps = headersList.map(toRegExp);

@@ -36,3 +36,9 @@ Object.keys(headers).map(function (header) {

exports.filterHeaders = filterHeaders;
/**
* @param {string|RegExp} value
* @return {RegExp}
*/
function toRegExp(value) {
return new RegExp(value);
}

@@ -49,26 +55,12 @@ /**

incomingMessage.on('response', function (response) {
// Back-up all required headers
var savedHeaders = headersToSave
? headersToSave.map(function (rawHeader) {
var header = rawHeader.toLowerCase();
return [header, response.headers[header]];
}).filter(function (header) {
return header[1] !== void 0;
})
: Object.keys(response.headers).map(function (header) {
return [header, response.headers[header]];
});
var headers = response.headers;
response.headers = {};
// Clean-up response headers
for (var k in response.headers) {
delete response.headers[k];
}
(headersToSave || Object.keys(headers)).forEach(function (header) {
header = header.toLocaleLowerCase();
var value = headers[header];
// Apply saved headers to response
savedHeaders.map(function (header) {
serverResponse.setHeader(header[0], header[1]);
if (value !== void 0) serverResponse.setHeader(header, value);
});
});
}
exports.saveHeaders = saveHeaders;
{
"name": "request-headers-filter",
"version": "1.0.3",
"version": "1.0.4",
"description": "Filter headers from request which will be passed to new request and/or response",

@@ -17,3 +17,3 @@ "main": "index.js",

"test": "nyc mocha",
"prepublish": "mocha"
"prepublishOnly": "mocha"
},

@@ -25,2 +25,5 @@ "repository": {

"keywords": [
"http",
"https",
"proxy",
"express",

@@ -40,14 +43,16 @@ "request",

"homepage": "https://github.com/L2jLiga/request-headers-filter#readme",
"dependencies": {
"@types/node": "*"
},
"devDependencies": {
"@types/chai": "4.1.4",
"@types/chai-http": "3.0.5",
"@types/mocha": "5.2.5",
"@types/nock": "9.3.0",
"@types/node": "8.10.29",
"@types/request": "2.47.1",
"chai": "4.1.2",
"chai-http": "4.2.0",
"@types/chai": "4.1.7",
"@types/chai-http": "4.2.0",
"@types/mocha": "5.2.6",
"@types/nock": "10.0.1",
"@types/request": "2.48.1",
"chai": "4.2.0",
"chai-http": "4.3.0",
"mocha": "5.2.0",
"nock": "9.6.1",
"nyc": "13.0.1",
"nock": "10.0.6",
"nyc": "14.0.0",
"request": "2.88.0"

@@ -54,0 +59,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc