mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-24 12:16:28 +01:00
Throw an error if HTTP file transfers are cleanly closed early
It seems that some HTTP servers can silently close the connection before the file has finished transferring. Since we count the transferred bytes anyway, throw an exception if we didn't get the number of bytes the server previously told us to expect.
This commit is contained in:
parent
8a2b566b18
commit
4da80dfae0
@ -328,6 +328,11 @@ public class HttpRequest implements Closeable, ProgressObservable {
|
||||
readBytes += len;
|
||||
checkInterrupted();
|
||||
}
|
||||
|
||||
if (contentLength >= 0 && contentLength != readBytes) {
|
||||
throw new IOException(String.format("Connection closed with %d bytes transferred, expected %d",
|
||||
readBytes, contentLength));
|
||||
}
|
||||
} finally {
|
||||
close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user