Skip to content

Commit cfbd1e3

Browse files
authored
fix(android): don't return 404 on empty files (#3323)
1 parent 2c9b5e1 commit cfbd1e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

android/capacitor/src/main/java/com/getcapacitor/WebViewLocalServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ private String getMimeType(String path, InputStream stream) {
356356
private int getStatusCode(InputStream stream, int defaultCode) {
357357
int finalStatusCode = defaultCode;
358358
try {
359-
if (stream.available() == 0) {
359+
if (stream.available() == -1) {
360360
finalStatusCode = 404;
361361
}
362362
} catch (IOException e) {
@@ -492,7 +492,7 @@ private InputStream getInputStream() {
492492
@Override
493493
public int available() throws IOException {
494494
InputStream is = getInputStream();
495-
return (is != null) ? is.available() : 0;
495+
return (is != null) ? is.available() : -1;
496496
}
497497

498498
@Override

0 commit comments

Comments
 (0)