From 791341f2109f50d6bd7ed34697c2532c0a3ace6d Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Sat, 19 Feb 2011 00:01:42 +0100 Subject: [PATCH] Fixed httpserver thereby also more optimized. --- src/main/java/org/dynmap/web/HttpResponse.java | 2 +- src/main/java/org/dynmap/web/HttpServerConnection.java | 5 +++-- src/main/java/org/dynmap/web/handlers/FileHandler.java | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/dynmap/web/HttpResponse.java b/src/main/java/org/dynmap/web/HttpResponse.java index 0f481002..0a6813b5 100644 --- a/src/main/java/org/dynmap/web/HttpResponse.java +++ b/src/main/java/org/dynmap/web/HttpResponse.java @@ -7,7 +7,7 @@ import java.util.Map; public class HttpResponse { private HttpServerConnection connection; - public String version = "1.0"; + public String version = "1.1"; public int statusCode = 200; public String statusMessage = "OK"; public Map fields = new HashMap(); diff --git a/src/main/java/org/dynmap/web/HttpServerConnection.java b/src/main/java/org/dynmap/web/HttpServerConnection.java index 850938ce..830ed5ae 100644 --- a/src/main/java/org/dynmap/web/HttpServerConnection.java +++ b/src/main/java/org/dynmap/web/HttpServerConnection.java @@ -1,5 +1,6 @@ package org.dynmap.web; +import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -116,9 +117,9 @@ public class HttpServerConnection extends Thread { try { socket.setSoTimeout(5000); InputStream in = socket.getInputStream(); - OutputStream out = socket.getOutputStream(); + BufferedOutputStream out = new BufferedOutputStream(socket.getOutputStream(), 40960); - printOut = new PrintStream(out); + printOut = new PrintStream(out, false); while (true) { HttpRequest request = new HttpRequest(); diff --git a/src/main/java/org/dynmap/web/handlers/FileHandler.java b/src/main/java/org/dynmap/web/handlers/FileHandler.java index 17f05afa..89c2dc9c 100644 --- a/src/main/java/org/dynmap/web/handlers/FileHandler.java +++ b/src/main/java/org/dynmap/web/handlers/FileHandler.java @@ -5,12 +5,14 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; +import java.util.logging.Logger; import org.dynmap.web.HttpHandler; import org.dynmap.web.HttpRequest; import org.dynmap.web.HttpResponse; public abstract class FileHandler implements HttpHandler { + protected static final Logger log = Logger.getLogger("Minecraft"); private byte[] readBuffer = new byte[40960]; private static Map mimes = new HashMap(); @@ -73,7 +75,6 @@ public abstract class FileHandler implements HttpHandler { String mimeType = getMimeTypeFromExtension(extension); response.fields.put("Content-Type", mimeType); - response.fields.put("Connection", "close"); OutputStream out = response.getBody(); try { int readBytes;