HttpDownloader: handle SSL errors like any other download error
Since SSLHandshakeException is a subclass of IOException, and all that is happening is rethrowing an Exception, instead pass this one through so it will be handled by the central Downloader error handling. That's currently just a Toast, but it can easily be expanded in the future.
This commit is contained in:
parent
b86a30d40f
commit
eb93a38cf5
@ -1,7 +1,5 @@
|
|||||||
package org.fdroid.fdroid.net;
|
package org.fdroid.fdroid.net;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
|
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
|
||||||
|
|
||||||
import org.fdroid.fdroid.FDroidApp;
|
import org.fdroid.fdroid.FDroidApp;
|
||||||
@ -18,7 +16,6 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLHandshakeException;
|
|
||||||
|
|
||||||
import info.guardianproject.netcipher.NetCipher;
|
import info.guardianproject.netcipher.NetCipher;
|
||||||
|
|
||||||
@ -72,25 +69,18 @@ public class HttpDownloader extends Downloader {
|
|||||||
return new BufferedInputStream(connection.getInputStream());
|
return new BufferedInputStream(connection.getInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get a remote file. Returns the HTTP response code.
|
/**
|
||||||
// If 'etag' is not null, it's passed to the server as an If-None-Match
|
* Get a remote file, checking the HTTP response code. If 'etag' is not
|
||||||
// header, in which case expect a 304 response if nothing changed.
|
* {@code null}, it's passed to the server as an If-None-Match header, in
|
||||||
// In the event of a 200 response ONLY, 'retag' (which should be passed
|
* which case expect a 304 response if nothing changed. In the event of a
|
||||||
// empty) may contain an etag value for the response, or it may be left
|
* 200 response ONLY, 'retag' (which should be passed empty) may contain
|
||||||
// empty if none was available.
|
* an etag value for the response, or it may be left empty if none was
|
||||||
|
* available.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void download() throws IOException, InterruptedException {
|
public void download() throws IOException, InterruptedException {
|
||||||
try {
|
setupConnection();
|
||||||
setupConnection();
|
doDownload();
|
||||||
doDownload();
|
|
||||||
} catch (SSLHandshakeException e) {
|
|
||||||
// TODO this should be handled better, it is not internationalised here
|
|
||||||
throw new IOException(
|
|
||||||
"A problem occurred while establishing an SSL " +
|
|
||||||
"connection. If this problem persists, AND you have a " +
|
|
||||||
"very old device, you could try using http instead of " +
|
|
||||||
"https for the repo URL." + Log.getStackTraceString(e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSwapUrl() {
|
private boolean isSwapUrl() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user