*) added environment variable DOCUMENT_ROOT

*) caught exception

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5466 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
low012 16 years ago
parent f26b8fcb1b
commit c1330f5743

@ -582,6 +582,8 @@ public final class httpdFileHandler {
pb = new ProcessBuilder(targetFile.getAbsolutePath());
String fileSeparator = System.getProperty("file.separator", "/");
// set environment variables
Map<String, String> env = pb.environment();
env.put("SERVER_SOFTWARE", getDefaultHeaders(path).get(httpResponseHeader.SERVER));
@ -603,6 +605,7 @@ public final class httpdFileHandler {
// env.put("AUTH_TYPE", ""); // TODO: implement
// env.put("REMOTE_USER", ""); // TODO: implement
// env.put("REMOTE_IDENT", ""); // I don't think we need this
env.put("DOCUMENT_ROOT", switchboard.getRootPath().getAbsolutePath() + fileSeparator + switchboard.getConfig("htDocsPath", "DATA/HTDOCS"));
if (requestHeader.getContentType() != null) {
env.put("CONTENT_TYPE", requestHeader.getContentType());
}
@ -616,9 +619,10 @@ public final class httpdFileHandler {
env.put("HTTP_" + requestHeaderKey.toUpperCase().replace("-", "_"), requestHeader.get(requestHeaderKey));
}
// TODO: set directory path for CGI script if this is necessary at all
//pb.directory(new File(targetFile.getAbsolutePath().substring(0, path.lastIndexOf("/"))));
int exitValue = 0;
String cgiBody = null;
try {
// start execution of script
Process p = pb.start();
@ -642,7 +646,7 @@ public final class httpdFileHandler {
}
int exitValue = p.exitValue();
exitValue = p.exitValue();
InputStream is = new BufferedInputStream(p.getInputStream());
@ -658,7 +662,7 @@ public final class httpdFileHandler {
if (indexOfDelimiter > -1) {
cgiHeader = cgiReturn.substring(0, indexOfDelimiter).split("\n");
}
String cgiBody = cgiReturn.substring(indexOfDelimiter + 1);
cgiBody = cgiReturn.substring(indexOfDelimiter + 1);
String key;
String value;
@ -681,6 +685,9 @@ public final class httpdFileHandler {
}
}
}
} catch (IOException ex) {
exitValue = -1;
}
/* did the script return an exit value != 0 and still there is supposed to be
* everything right with the HTTP status? -> change status to 500 since 200 would

Loading…
Cancel
Save