Comparing version 0.1.2 to 0.1.3
var fs = require('fs'), | ||
path = require('path'), | ||
union = require('../lib'), | ||
@@ -10,3 +11,3 @@ director = require('director'), | ||
before: [ | ||
favicon('./favicon.png'), | ||
favicon(path.join(__dirname, 'favicon.png')), | ||
function (req, res) { | ||
@@ -21,3 +22,3 @@ var found = router.dispatch(req, res); | ||
router.get(/\/foo/, function () { | ||
router.get('/foo', function () { | ||
this.res.writeHead(200, { 'Content-Type': 'text/plain' }) | ||
@@ -27,3 +28,3 @@ this.res.end('hello world\n'); | ||
router.post(/\/foo/, { stream: true }, function () { | ||
router.post('/foo', { stream: true }, function () { | ||
var req = this.req, | ||
@@ -43,2 +44,3 @@ res = this.res, | ||
server.listen(8080); | ||
console.log('union with director running on 8080'); | ||
console.log('union with director running on 8080'); | ||
@@ -32,10 +32,13 @@ /* | ||
HttpStream.prototype.pipeState = function (source) { | ||
this.url = source.url; | ||
this.headers = source.headers; | ||
this.method = source.method; | ||
if (source.url) { | ||
this.url = source.url; | ||
} | ||
if (source.query) { | ||
this.query = source.query; | ||
} | ||
else { | ||
else if (source.url) { | ||
this.query = ~source.url.indexOf('?') | ||
@@ -42,0 +45,0 @@ ? qs.parse(url.parse(source.url).query) |
@@ -23,3 +23,2 @@ /* | ||
this.response = options.response; | ||
this.once('pipe', this.pipeResponse); | ||
}; | ||
@@ -39,2 +38,12 @@ | ||
// | ||
// Create pass-thru for the necessary | ||
// `http.ServerResponse` methods. | ||
// | ||
['setHeader', 'getHeader', 'removeHeader'].forEach(function (method) { | ||
ResponseStream.prototype[method] = function () { | ||
return this.response[method].apply(this.response, arguments); | ||
}; | ||
}); | ||
ResponseStream.prototype.end = function (data) { | ||
@@ -41,0 +50,0 @@ if (data && this.writable) { |
{ | ||
"name": "union", | ||
"description": "A hybrid buffered / streaming middleware kernel backwards compatible with connect.", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Nodejitsu Inc. <info@nodejitsu.com>", | ||
@@ -17,2 +17,3 @@ "contributors": [ | ||
"devDependencies": { | ||
"ecstatic": "git://github.com/jesusabdullah/node-ecstatic.git", | ||
"director": "1.x.x", | ||
@@ -19,0 +20,0 @@ "request": "2.x.x", |
@@ -14,6 +14,8 @@ /* | ||
request = require('request'), | ||
vows = require('vows'); | ||
vows = require('vows'), | ||
macros = require('./helpers/macros'); | ||
var examplesDir = path.join(__dirname, '..', 'examples'), | ||
simpleScript = path.join(examplesDir, 'simple.js'), | ||
fooURI = 'http://localhost:8080/foo', | ||
server; | ||
@@ -25,3 +27,3 @@ | ||
topic: function () { | ||
server = spawn('node', [simpleScript]); | ||
server = spawn(process.argv[0], [simpleScript]); | ||
server.stdout.on('data', this.callback.bind(this, null)); | ||
@@ -31,9 +33,17 @@ }, | ||
topic: function () { | ||
request({ uri: 'http://localhost:8080/foo' }, this.callback); | ||
request({ uri: fooURI }, this.callback); | ||
}, | ||
"it should respond with `hello world`": function (err, res, body) { | ||
assert.isTrue(!err); | ||
assert.equal(res.statusCode, 200); | ||
macros.assertValidResponse(err, res); | ||
assert.equal(body, 'hello world\n'); | ||
} | ||
}, | ||
"a POST request to `/foo`": { | ||
topic: function () { | ||
request.post({ uri: fooURI }, this.callback); | ||
}, | ||
"it should respond with `wrote to a stream!`": function (err, res, body) { | ||
macros.assertValidResponse(err, res); | ||
assert.equal(body, 'wrote to a stream!'); | ||
} | ||
} | ||
@@ -48,2 +58,3 @@ } | ||
} | ||
}).export(module); | ||
}).export(module); | ||
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
24390
20
638
4