Created
April 2, 2011 05:19
-
-
Save markc/899249 to your computer and use it in GitHub Desktop.
serve_cgi
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 serve_cgi(filename, res, get, post, method, vhost, port, pinfo, get, sname, uri, droot) { | |
var env = { | |
CONTENT_LENGTH: post.length, | |
CONTENT_TYPE: 'application/x-www-form-urlencoded', | |
DOCUMENT_ROOT: droot, | |
GATEWAY_INTERFACE: 'CGI/1.1', | |
HTTP_HOST: vhost, | |
QUERY_STRING: get, | |
REDIRECT_STATUS: '200', | |
REQUEST_METHOD: method, | |
REQUEST_URI: uri, | |
SCRIPT_FILENAME: filename, | |
SCRIPT_NAME: sname, | |
SERVER_NAME: vhost, | |
SERVER_PORT: port, | |
SERVER_PROTOCOL: 'HTTP/1.1', | |
SERVER_SOFTWARE: 'Node/'+process.version+' (Nodality/20110402)', | |
} | |
var cgi = spawn(filename, [], env); | |
cgi.stdout.on('data', function (data) {res.write(data, 'binary'); }); | |
cgi.on('exit', function (code) {res.end();}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment