Created
September 4, 2009 21:24
-
-
Save dantman/181145 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Dummyware(app) { | |
return function(env) { | |
var r = app(env); | |
var istream = r.body; | |
var ostream = r.body = new MemoryStream(); | |
async(function chunked() { | |
if ( istream.canRead ) | |
ostream.write(istream.read(Infinity)); | |
if ( !istream.seenEOF ) | |
async(chunked); | |
else ostream.closed(); | |
}); | |
return r; | |
}; | |
} | |
// or | |
function Dummyware(app) { | |
return function(env) { | |
var istream = new MemoryStream(); | |
var ostream = env["jsgi.output"]; | |
env["jsgi.output"] = istream; | |
async(function chunked() { | |
if ( istream.canRead ) | |
ostream.write(istream.read(Infinity)); | |
if ( !istream.seenEOF ) | |
async(chunked); | |
else ostream.closed(); | |
}); | |
return app(env); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment