mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-12 15:56:00 +08:00
Buffer the Outputstream for response
Add html header to /players
This commit is contained in:
parent
dd299cd8ee
commit
50e3d839e3
@ -17,10 +17,7 @@ import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.*;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.security.*;
|
||||
@ -97,9 +94,15 @@ public class WebServer {
|
||||
|
||||
String content = response.getContent();
|
||||
exchange.sendResponseHeaders(response.getCode(), content.length());
|
||||
os = exchange.getResponseBody();
|
||||
|
||||
os.write(content.getBytes());
|
||||
try (BufferedOutputStream out = new BufferedOutputStream(exchange.getResponseBody())) {
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(content.getBytes())) {
|
||||
byte[] buffer = new byte[2048];
|
||||
int count;
|
||||
while ((count = bis.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
throw e;
|
||||
|
@ -20,7 +20,7 @@ public class PlayersPageResponse extends Response {
|
||||
}
|
||||
|
||||
public static String buildContent(List<UserData> cached) {
|
||||
StringBuilder html = new StringBuilder("<h1>Cached Players</h1><p>");
|
||||
StringBuilder html = new StringBuilder("<!DOCTYPE html><html><body><h1>Cached Players</h1><p>");
|
||||
|
||||
int size = cached.size();
|
||||
html.append(size)
|
||||
@ -37,7 +37,7 @@ public class PlayersPageResponse extends Response {
|
||||
}
|
||||
i++;
|
||||
}
|
||||
html.append("</tr></table>");
|
||||
html.append("</tr></table></body></html>");
|
||||
return html.toString();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user