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,
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,
}
String type = uriParts[off + 0];
- String id = uriParts[off + 1];
+ String id = uri.substring(startAt + type.length() + "/".length());
InputStream in = null;
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,
}
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);