From bd743ca20c648a0c195dcd0650a3b2c5600b7833 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Thu, 21 May 2020 22:12:35 +0200 Subject: [PATCH] code cleanup --- src/be/nikiroo/fanfix/library/WebLibraryServer.java | 5 ++--- src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) 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, "", -- 2.27.0