update from master
[fanfix.git] / library / WebLibraryServer.java
index 22f36e91f5729a7bfef72fe9c98d2a7fa157a6ec..1fce3911eb67f5b47cb95198a9a8c542da9ebf2d 100644 (file)
@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -217,9 +218,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,
@@ -396,7 +396,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                }
 
                String type = uriParts[off + 0];
-               String id = uriParts[off + 1];
+               String id = URLDecoder.decode(uriParts[off + 1], "UTF-8");
 
                InputStream in = null;
 
@@ -447,7 +447,7 @@ public class WebLibraryServer extends WebLibraryServerHtml {
                }
 
                String type = uriParts[off + 0];
-               String id = uriParts[off + 1];
+               String id = URLDecoder.decode(uriParts[off + 1], "UTF-8");
 
                if ("source".equals(type)) {
                        sourceCover(id, login, luid);