From: Niki Roo Date: Thu, 21 May 2020 20:12:35 +0000 (+0200) Subject: code cleanup X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=bd743ca20c648a0c195dcd0650a3b2c5600b7833;p=fanfix.git code cleanup --- diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index 22f36e9..56d78ed 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServer.java @@ -217,9 +217,8 @@ public class WebLibraryServer extends WebLibraryServerHtml { jsons.add(JsonIO.toJson(meta)); } - return newInputStreamResponse("application/json", - new ByteArrayInputStream( - new JSONArray(jsons).toString().getBytes())); + return NanoHTTPD.newFixedLengthResponse(Status.OK, + "application/json", new JSONArray(jsons).toString()); } return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST, diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java b/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java index 3dbc4ae..63c50c5 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java @@ -759,7 +759,7 @@ abstract class WebLibraryServerHtml implements Runnable { NanoHTTPD.MIME_PLAINTEXT, "Error when processing request"); } } - + protected Response newInputStreamResponse(String mimeType, InputStream in) { if (in == null) { return NanoHTTPD.newFixedLengthResponse(Status.NO_CONTENT, "",