for #404 a few more tweaks to make sure things are getting closed!
This commit is contained in:
parent
b3f8ac0a5b
commit
b6939dcce4
@ -184,6 +184,7 @@ public abstract class Downloader {
|
|||||||
|
|
||||||
}
|
}
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendProgress(int bytesRead, int totalBytes) {
|
protected void sendProgress(int bytesRead, int totalBytes) {
|
||||||
|
@ -34,6 +34,7 @@ public class HttpDownloader extends Downloader {
|
|||||||
protected static final String HEADER_FIELD_ETAG = "ETag";
|
protected static final String HEADER_FIELD_ETAG = "ETag";
|
||||||
|
|
||||||
protected HttpURLConnection connection;
|
protected HttpURLConnection connection;
|
||||||
|
private InputStream stream;
|
||||||
private int statusCode = -1;
|
private int statusCode = -1;
|
||||||
private boolean onlyStream = false;
|
private boolean onlyStream = false;
|
||||||
|
|
||||||
@ -64,7 +65,8 @@ public class HttpDownloader extends Downloader {
|
|||||||
|
|
||||||
public InputStream getInputStream() throws IOException {
|
public InputStream getInputStream() throws IOException {
|
||||||
setupConnection();
|
setupConnection();
|
||||||
return new BufferedInputStream(connection.getInputStream());
|
stream = new BufferedInputStream(connection.getInputStream());
|
||||||
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferedReader getBufferedReader () throws IOException
|
public BufferedReader getBufferedReader () throws IOException
|
||||||
@ -169,6 +171,12 @@ public class HttpDownloader extends Downloader {
|
|||||||
|
|
||||||
public void close ()
|
public void close ()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
if (stream != null)
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
catch (IOException e) {}
|
||||||
|
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user