Skip to content

Commit

Permalink
Catch unanticipated EOFException due to empty stream when redirecting.
Browse files Browse the repository at this point in the history
  • Loading branch information
customautosys authored and ath0mas committed Feb 14, 2024
1 parent 59b804c commit 9d95763
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/android/com/silkimen/http/HttpRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -2489,10 +2490,14 @@ protected HttpRequest copy(final InputStream input, final OutputStream output) t
public HttpRequest run() throws IOException {
final byte[] buffer = new byte[bufferSize];
int read;
while ((read = input.read(buffer)) != -1) {
output.write(buffer, 0, read);
totalWritten += read;
progress.onUpload(totalWritten, totalSize);
try{
while ((read = input.read(buffer)) != -1) {
output.write(buffer, 0, read);
totalWritten += read;
progress.onUpload(totalWritten, totalSize);
}
}catch(EOFException e){
e.printStackTrace();
}
return HttpRequest.this;
}
Expand Down

0 comments on commit 9d95763

Please sign in to comment.