Socket
Socket
Sign inDemoInstall

nodecap2

Package Overview
Dependencies
23
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

test/multiple_headers_spec.js

6

examples/example.js

@@ -67,2 +67,8 @@ var ICAPServer = require('../').ICAPServer;

}
// only example how are presented multiple headers in request
req.headers['X-Example'] = ['flag{12345-FirstHeader}', 'second header'];
// Response will contain two different header:
// X-Example: flag{12345-FirstHeader}
// X-Example: second header
icapRes.setIcapStatusCode(200);

@@ -69,0 +75,0 @@ icapRes.setIcapHeaders(icapReq.headers);

2

package.json
{
"name": "nodecap2",
"version": "2.0.1",
"version": "2.1.0",
"description": "ICAP server framework for node.js - create custom HTTP proxy filters for Squid, etc.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,3 +7,2 @@ nodecap2

It is fork of [nodecap](https://www.npmjs.com/package/nodecap) with some fixes and performance improvements.
I didn't change gh pages, docs and tests yet.

@@ -10,0 +9,0 @@ ICAP server framework for node.js - create custom HTTP proxy filters for Squid, etc. **nodecap** implements the [ICAP protocol](http://www.icap-forum.org/documents/specification/rfc3507.txt).

@@ -39,15 +39,16 @@ "use strict";

}
var tokens = line.str.split(':');
if (tokens.length < 2) {
var str = line.str;
var delim = str.indexOf(":");
if (delim < 0) {
return null;
}
var header = tokens.shift();
var value = tokens.join(':');
if (value.length > 0 && value[0] === ' ') {
value = value.substr(1)
var header = str.slice(0, delim);
delim += 1;
if (delim < str.length && str.charAt(delim) === ' ') {
++delim;
}
var result = {};
result[header] = value;
var value = str.slice(delim);
return {
header: result,
header: header,
value: value,
index: line.index

@@ -54,0 +55,0 @@ };

@@ -246,3 +246,11 @@ "use strict";

while ((header = this.read(helpers.header)) !== null) {
_.assign(headers, header.header);
var headerName = header.header;
if (headerName in headers) {
if (!Array.isArray(headers[headerName])) {
headers[headerName] = [headers[headerName]];
}
headers[headerName].push(header.value);
} else {
headers[headerName] = header.value;
}

@@ -249,0 +257,0 @@ if (this.read(helpers.newline).newline) {

@@ -21,5 +21,5 @@ "use strict";

this.icapStatus = null;
this.icapHeaders = null;
this.icapHeaders = {};
this.httpMethod = null;
this.httpHeaders = null;
this.httpHeaders = {};
this.buffer = null;

@@ -41,3 +41,3 @@ };

setIcapHeaders: function(headers) {
this.icapHeaders = _.assign(this.icapHeaders || {}, headers);
this.icapHeaders = _.assign(this.icapHeaders, headers);
},

@@ -59,3 +59,3 @@ setHttpMethod: function(options) {

setHttpHeaders: function(headers) {
this.httpHeaders = _.assign(this.httpHeaders || {}, headers);
this.httpHeaders = _.assign(this.httpHeaders, headers);
},

@@ -73,2 +73,16 @@ hasFilter: function() {

},
_joinHeaders: function (status, headers) {
var block = status.join(' ') + crlf;
for (var key in headers) {
var value = headers[key];
if (Array.isArray(value)) {
for (var i = 0, l=value.length; i< l; ++i) {
block += key + ": " + value[i] + crlf;
}
} else {
block += key + ": " + value + crlf;
}
}
return block;
},
writeHeaders: function(hasBody) {

@@ -80,12 +94,6 @@ var headerBlock = '';

}
this.icapHeaders = this.icapHeaders || {};
// http status/headers
if (!!this.httpMethodType) {
headerBlock += this.httpMethod.join(' ') + crlf;
_.each(this.httpHeaders || {}, function(value, key) {
headerBlock += key + ': ' + value + crlf;
});
headerBlock += crlf;
headerBlock = this._joinHeaders(this.httpMethod, this.httpHeaders) + crlf;
var encapsulated = [];

@@ -116,7 +124,3 @@ var bodyType = "null-body";

// icap status/headers
var icapBlock = this.icapStatus.join(' ') + crlf;
_.each(this.icapHeaders, function(value, key) {
icapBlock += key + ': ' + value + crlf;
});
var icapBlock = this._joinHeaders(this.icapStatus, this.icapHeaders);
this.stream.write(icapBlock + crlf + headerBlock);

@@ -123,0 +127,0 @@ },

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc