From cfbd1e3ebd3d981d6878eb465e24b45bf0a8cf31 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Thu, 23 Jul 2020 20:25:22 +0200 Subject: [PATCH] fix(android): don't return 404 on empty files (#3323) --- .../src/main/java/com/getcapacitor/WebViewLocalServer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java index 43f965b46..d632065a9 100755 --- a/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java +++ b/android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java @@ -356,7 +356,7 @@ private String getMimeType(String path, InputStream stream) { private int getStatusCode(InputStream stream, int defaultCode) { int finalStatusCode = defaultCode; try { - if (stream.available() == 0) { + if (stream.available() == -1) { finalStatusCode = 404; } } catch (IOException e) { @@ -492,7 +492,7 @@ private InputStream getInputStream() { @Override public int available() throws IOException { InputStream is = getInputStream(); - return (is != null) ? is.available() : 0; + return (is != null) ? is.available() : -1; } @Override