Comparing version 0.1.0 to 0.1.1
@@ -12,5 +12,16 @@ /* | ||
var headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Content-Type': 'text/plain' | ||
}; | ||
function mix(reciever, sender) { | ||
Object.keys(sender).forEach(function (key) { | ||
if (!reciever.hasOwnProperty(key)) { | ||
reciever[key] = sender[key]; | ||
} | ||
}); | ||
return reciever; | ||
} | ||
exports.headers = headers; | ||
@@ -33,3 +44,3 @@ | ||
code = ((req.method === 'GET' || req.method === 'HEAD' || req.method === 'OPTIONS') ? 200 : 403); | ||
res.writeHead(code, headers); | ||
@@ -113,3 +124,3 @@ res.end(p.query || ''); | ||
json = (p.query ? JSON.stringify(qs.parse(p.query)) : '{ "echo": true }'); | ||
if (req.body) { | ||
@@ -119,5 +130,5 @@ json = JSON.stringify(req.body); | ||
res.writeHead(200, { | ||
'Content-type': 'application/json' | ||
}); | ||
res.writeHead(200, mix({ | ||
'Content-Type': 'application/json' | ||
}, headers)); | ||
res.end(json); | ||
@@ -159,7 +170,6 @@ }; | ||
res.writeHead(code, { | ||
'Content-type': 'application/json' | ||
}); | ||
res.writeHead(code, mix({ | ||
'Content-Type': 'application/json' | ||
}, headers)); | ||
res.end(json); | ||
}; |
@@ -5,3 +5,3 @@ { | ||
"author": "Dav Glass <davglass@gmail.com>", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"devDependencies": { | ||
@@ -8,0 +8,0 @@ "vows": "*", |
@@ -176,2 +176,3 @@ var vows = require('vows'), | ||
"with OK body": function(topic) { | ||
assert.equal(topic.headers['access-control-allow-origin'], '*'); | ||
assert.equal(topic.code, 200); | ||
@@ -189,2 +190,3 @@ assert.equal(topic.body, 'OK'); | ||
"with Not Found body": function(topic) { | ||
assert.equal(topic.headers['access-control-allow-origin'], '*'); | ||
assert.equal(topic.code, 404); | ||
@@ -250,2 +252,3 @@ assert.equal(topic.body, 'Not Found'); | ||
"with query body": function(topic) { | ||
assert.equal(topic.headers['access-control-allow-origin'], '*'); | ||
assert.equal(topic.code, 200); | ||
@@ -263,2 +266,3 @@ assert.equal(topic.body, 'foo=bar'); | ||
"with query body": function(topic) { | ||
assert.equal(topic.headers['access-control-allow-origin'], '*'); | ||
assert.equal(topic.code, 200); | ||
@@ -265,0 +269,0 @@ assert.equal(topic.body, ''); |
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
39112
920