Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dantman
Created September 4, 2009 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dantman/181145 to your computer and use it in GitHub Desktop.
Save dantman/181145 to your computer and use it in GitHub Desktop.
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