X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fasynctasks%2FGetUrlSize.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fasynctasks%2FGetUrlSize.java;h=74968df9508599744504dec070bf568297ef992c;hp=b34f62e885937bf33ab2d81c2669ce0e29ed9a8f;hb=ba4a1c032dbffde044b70c804f9d3c1f1ba7b939;hpb=d665a89a28f33c9feaaf217f7cabc0c809cb7107 diff --git a/app/src/main/java/com/stoutner/privacybrowser/asynctasks/GetUrlSize.java b/app/src/main/java/com/stoutner/privacybrowser/asynctasks/GetUrlSize.java index b34f62e8..74968df9 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/asynctasks/GetUrlSize.java +++ b/app/src/main/java/com/stoutner/privacybrowser/asynctasks/GetUrlSize.java @@ -28,7 +28,6 @@ import android.widget.TextView; import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.helpers.ProxyHelper; -import java.io.IOException; import java.lang.ref.WeakReference; import java.net.HttpURLConnection; import java.net.Proxy; @@ -81,10 +80,10 @@ public class GetUrlSize extends AsyncTask { Proxy proxy = proxyHelper.getCurrentProxy(context); // Open a connection to the URL. No data is actually sent at this point. - HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(proxy); + HttpURLConnection httpUrlConnection = (HttpURLConnection) url.openConnection(proxy); // Add the user agent to the header property. - httpURLConnection.setRequestProperty("User-Agent", userAgent); + httpUrlConnection.setRequestProperty("User-Agent", userAgent); // Add the cookies if they are enabled. if (cookiesEnabled) { @@ -94,7 +93,7 @@ public class GetUrlSize extends AsyncTask { // Only add the cookies if they are not null. if (cookiesString != null) { // Add the cookies to the header property. - httpURLConnection.setRequestProperty("Cookie", cookiesString); + httpUrlConnection.setRequestProperty("Cookie", cookiesString); } } @@ -103,19 +102,19 @@ public class GetUrlSize extends AsyncTask { // Exit if the task has been cancelled. if (isCancelled()) { // Disconnect the HTTP URL connection. - httpURLConnection.disconnect(); + httpUrlConnection.disconnect(); // Return the formatted file size string. return formattedFileSize; } // Get the status code. - int responseCode = httpURLConnection.getResponseCode(); + int responseCode = httpUrlConnection.getResponseCode(); // Exit if the task has been cancelled. if (isCancelled()) { // Disconnect the HTTP URL connection. - httpURLConnection.disconnect(); + httpUrlConnection.disconnect(); // Return the formatted file size string. return formattedFileSize; @@ -127,7 +126,7 @@ public class GetUrlSize extends AsyncTask { formattedFileSize = context.getString(R.string.invalid_url); } else { // The response code is not an error message. // Get the content length header. - String contentLengthString = httpURLConnection.getHeaderField("Content-Length"); + String contentLengthString = httpUrlConnection.getHeaderField("Content-Length"); // Define the file size long. long fileSize; @@ -143,9 +142,9 @@ public class GetUrlSize extends AsyncTask { } } finally { // Disconnect the HTTP URL connection. - httpURLConnection.disconnect(); + httpUrlConnection.disconnect(); } - } catch (IOException exception) { + } catch (Exception exception) { // Set the formatted file size to indicate a bad URL. formattedFileSize = context.getString(R.string.invalid_url); }