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

echoecho

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

echoecho - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

48

lib/scheme.js

@@ -57,31 +57,36 @@ /*

var post = function (method, req, res) {
var code = ((req.method === method) ? 200 : 403),
data = '',
var data = '',
gotData = false,
sent = false,
body = '',
end = function () {
if (!sent) {
sent = true;
var b = qs.parse(data);
if (Object.keys(b).length > 0) {
body = data;
} else {
body = String(Object.keys(b).length);
}
res.writeHead(code, headers);
res.end(body);
}
};
sent = false;
function end() {
if (sent) { return; }
if (req.body && Object.keys(req.body).length) { //Express
var body = Object.keys(qs.parse(data)).length > 0 ? data : '',
code;
if (req.method === method) {
code = body ? 200 : 204;
} else {
code = 403;
}
sent = true;
res.writeHead(code, headers);
res.end(body);
}
// Check if we have data, and aid Express' `req` object.
if (req.body && Object.keys(req.body).length) {
data = qs.stringify(req.body);
gotData = true;
data = qs.stringify(req.body);
end();
} else {
req.on('data', function (c) {
data += c;
gotData = true;
data += c;
});

@@ -91,4 +96,3 @@

//Seems as if the post doesn't have data
//the end event doesn't fire??
// Seems as if the post doesn't have data the end event doesn't fire??
setTimeout(function () {

@@ -95,0 +99,0 @@ if (!gotData) {

@@ -5,3 +5,3 @@ {

"author": "Dav Glass <davglass@gmail.com>",
"version": "0.1.3",
"version": "0.1.4",
"devDependencies": {

@@ -8,0 +8,0 @@ "vows": "*",

@@ -293,2 +293,15 @@ var vows = require('vows'),

},
"and post with no body": {
topic: function() {
fetch({
method: 'POST',
path: '/foo/bar/baz/echo/post',
body: ''
}, this.callback);
},
"with query body": function(topic) {
assert.equal(topic.code, 204);
assert.equal(topic.body, '');
}
},
"and post mismatch": {

@@ -606,3 +619,3 @@ topic: function() {

return [one, two]
},

@@ -609,0 +622,0 @@ 'different paths': function(topic) {

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