svalue + "].");
getServer().errlog(this, msg);
// Throw an HTTPException:
reply = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
reply.setContent("CGI script emited invalid status.");
throw new HTTPException(reply);
}
// we will use the default for this frame, but remove
// the length calculated from the script size.
reply = createDefaultReply(request, status);
reply.setContentLength(-1);
} else {
// No status code available, any location header ?
if (location != null) {
reply = request.makeReply(HTTP.FOUND);
} else {
reply = createDefaultReply(request, HTTP.OK);
reply.setContentLength(-1);
}
}
// Set up the location header if needed:
if ( location != null ) {
try {
reply.setLocation(new URL(getURL(request), location));
} catch (MalformedURLException ex) {
// This should really not happen:
getServer().errlog(this, "unable to create location url "+
location+
" in base "+getURL(request));
}
}
// And then, the remaining headers:
Enumeration e = h.enumerateHeaders();
if ( e != null ) {
while ( e.hasMoreElements() ) {
String hname = (String) e.nextElement();
reply.setValue(hname, (String) h.getValue(hname));
}
}
reply.setStream(p.getInputStream()) ;
} catch (IOException ex) {
ex.printStackTrace();
} catch (MimeParserException ex) {
// This script has generated invalid output:
String msg = (getURL(request)
+": emited invalid output ["+
ex.getMessage() +"]");
getServer().errlog(this, msg);
// Throw an HTTPException:
Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
error.setContent("CGI error: unable to parse script headers.") ;
throw new HTTPException (error) ;
}
if (reply != null) {
reply.setDynamic(true);
}
return reply ;