X-Git-Url: https://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FWebLibraryServer.java;h=6260f6a5c6744d9c9411d0941ad3ad0a54c5e58b;hb=1dbed6237611f74292af13f20f9d80c446a60020;hp=22f36e91f5729a7bfef72fe9c98d2a7fa157a6ec;hpb=8a32bb943d4173511aec62aa87462abbf93cdcc9;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index 22f36e9..6260f6a 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, @@ -388,7 +387,11 @@ public class WebLibraryServer extends WebLibraryServerHtml { protected Response getCover(String uri, WLoginResult login) throws IOException { String[] uriParts = uri.split("/"); + int startAt = 0; int off = 2; // "" and "cover" + for (int i = 0; i < off; i++) { + startAt += uriParts[i].length() + "/".length(); + } if (uriParts.length < off + 2) { return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST, @@ -396,7 +399,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { } String type = uriParts[off + 0]; - String id = uriParts[off + 1]; + String id = uri.substring(startAt + type.length() + "/".length()); InputStream in = null; @@ -430,6 +433,10 @@ public class WebLibraryServer extends WebLibraryServerHtml { throws IOException { String[] uriParts = uri.split("/"); int off = 2; // "" and "cover" + int startAt = 0; + for (int i = 0; i < off; i++) { + startAt += uriParts[i].length() + "/".length(); + } if (uriParts.length < off + 2) { return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST, @@ -447,7 +454,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { } String type = uriParts[off + 0]; - String id = uriParts[off + 1]; + String id = uri.substring(startAt + type.length() + "/".length()); if ("source".equals(type)) { sourceCover(id, login, luid);