Merge pull request #51 from clochardpagan/master

Fixed header addition on file serving for android
This commit is contained in:
Michael Bykovski 2019-11-26 08:47:52 +01:00 committed by GitHub
commit b91045b46f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -234,7 +234,16 @@ public class NanoHTTPDWebserver extends NanoHTTPD {
File file = new File(responseObject.getString("path"));
Uri uri = Uri.fromFile(file);
String mime = getMimeType(uri.toString());
return serveFile(session.getHeaders(), file, mime);
Response res = serveFile(session.getHeaders(), file, mime);
Iterator<?> keys = responseObject.getJSONObject("headers").keys();
while (keys.hasNext()) {
String key = (String) keys.next();
res.addHeader(
key,
responseObject.getJSONObject("headers").getString(key)
);
}
return res;
} catch (JSONException e) {
e.printStackTrace();
}