New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hammock

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hammock - npm Package Compare versions

Comparing version 0.1.7 to 0.1.9

43

lib/request.js

@@ -10,4 +10,4 @@ var Cookies = require('cookies');

/**
* Mock request object for sending to the router without needing a server.
**/
* Mock request object for sending to the router without needing a server.
**/
var MockRequest = function(options) {

@@ -17,13 +17,21 @@ if (!(this instanceof MockRequest)) {

}
EventEmitter.call(this, options);
this.body = '';
this.httpVersion = '1.1';
this.url = options.url || '/';
this.query = url.parse(this.url, true).query;
this.headers = this._headers = options.headers || {};
this.headers['transfer-coding'] = 'chunked';
this.headers = this._headers = {};
// setHeader now applies toLowerCase the names to mirror native node behaviour
var self = this;
_.each(options.headers, function(v, k) {
self.setHeader(k, v);
});
this.setHeader('transfer-encoding', 'chunked');
this.method = options.method || 'GET';
this.connection = {};
this.connection = this.socket = {};
// this.buffer = [];

@@ -33,3 +41,3 @@

_.forEach(_.keys(options.cookies || {}) ,function(key) {
_.forEach(_.keys(options.cookies || {}), function(key) {
cookieBuffer.push(key + '=' + options.cookies[key]);

@@ -49,9 +57,7 @@ });

return ret;
} else if (clobber || !this.headers.hasOwnProperty(name)) {
this.headers[name.toLowerCase()] = value;
} else {
this.headers[name.toLowerCase()] += ',' + value;
}
else if (clobber || !this.headers.hasOwnProperty(name)) {
this.headers[name] = value;
}
else {
this.headers[name] += ',' + value;
}
};

@@ -62,4 +68,3 @@

return http.ClientRequest.prototype.getHeader.call(this, name);
}
else {
} else {
return this.headers[name];

@@ -75,6 +80,8 @@ }

this.body += str;
};
};
MockRequest.prototype.end = function(str) {
this.write(str);
if (str) {
this.write(str);
}
this.emit('data', new Buffer(this.body));

@@ -84,2 +91,2 @@ this.emit('end');

module.exports = MockRequest;
module.exports = MockRequest;
{
"name": "hammock",
"version": "0.1.7",
"version": "0.1.9",
"description": "Node.js mock / polyfill http object library for http req / res",

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

@@ -30,3 +30,3 @@ var test = require('tape');

req.on('data', function(body) {
t.equals(body, 'foobar', 'Body should have been pushed from mock req.');
t.equals(body.toString(), 'foobar', 'Body should have been pushed from mock req.');
t.end();

@@ -37,2 +37,2 @@ });

req.end('bar');
});
});
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