Add max-sessions setting to configuration.txt - limits concurrent threads and sessions on internal web server

This commit is contained in:
Mike Primm 2011-07-25 20:34:37 -05:00
parent 42132328cd
commit aa29ddf141
4 changed files with 37 additions and 4 deletions

View file

@ -26,6 +26,7 @@ public class HttpServerConnection extends Thread {
private Socket socket;
private HttpServer server;
private boolean do_shutdown;
private boolean can_keepalive;
private PrintStream printOut;
private StringWriter sw = new StringWriter();
@ -36,6 +37,7 @@ public class HttpServerConnection extends Thread {
this.socket = socket;
this.server = server;
do_shutdown = false;
can_keepalive = false;
}
private final static void readLine(InputStream in, StringWriter sw) throws IOException {
@ -159,7 +161,9 @@ public class HttpServerConnection extends Thread {
boolean iskeepalive = false;
String keepalive = request.fields.get(HttpField.Connection);
if((keepalive != null) && (keepalive.toLowerCase().indexOf("keep-alive") >= 0)) {
iskeepalive = true;
/* See if we're clear to do keepalive */
if(!iskeepalive)
iskeepalive = server.canKeepAlive(this);
}
// TODO: Optimize HttpHandler-finding by using a real path-aware tree.
@ -193,6 +197,9 @@ public class HttpServerConnection extends Thread {
response.fields.put(HttpField.Connection, "keep-alive");
response.fields.put("Keep-Alive", "timeout=5");
}
else {
response.fields.put(HttpField.Connection, "close");
}
try {
handler.handle(relativePath, request, response);
} catch (IOException e) {