| Paste number 84375: | cgi-script-responder |
| Pasted by: | cgay |
| When: | 2 years, 6 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1T3R |
| Channel: | #dylan |
| Paste contents: |
define method cgi-script-responder
(script :: <locator>)
let command = as(<string>, script);
log-debug("cgi-script-responder(%=)", command);
let request :: <request> = current-request();
let env :: <string-table> = make-cgi-environment(script);
for (value keyed-by key in env)
log-debug(" %s: %s", key, value);
end;
let (exit-code, signal, child, stdin, stdout)
= run-application(list(command),
asynchronous?: #t,
under-shell?: #f,
environment: env,
// TODO: see if RFC sez anything about this
//working-directory: foo,
input: stream:,
output: stream:,
error: null:, // temp
// Windows options, ignored on posix systems
activate?: #f,
minimize?: #t,
hide?: #t);
block ()
if (exit-code ~= 0)
log-error("CGI failed to launch: %s, exit-code: %s, signal: %s",
command, exit-code, signal);
else
close(stdin); // temp
output(read-to-end(stdout));
end;
cleanup
log-debug("CGI waiting: %s", command);
let (exit-code, signal) = wait-for-application-process(child);
log-debug("CGI terminated: %s, exit-code: %s, signal: %s",
command, exit-code, signal);
end;
end method cgi-script-responder;
This paste has no annotations.