Refactoring

This commit is contained in:
M66B
2022-08-14 07:51:50 +02:00
parent 77b7426c8e
commit 0002857aff
5 changed files with 22 additions and 19 deletions

View File

@@ -673,7 +673,7 @@ public class ConnectionHelper {
static HttpURLConnection openConnectionUnsafe(Context context, URL url, int ctimeout, int rtimeout) throws IOException {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean open_unsafe = prefs.getBoolean("open_unsafe", true);
boolean open_safe = prefs.getBoolean("open_safe", false);
int redirects = 0;
while (true) {
@@ -685,7 +685,7 @@ public class ConnectionHelper {
urlConnection.setInstanceFollowRedirects(true);
if (urlConnection instanceof HttpsURLConnection) {
if (open_unsafe)
if (!open_safe)
((HttpsURLConnection) urlConnection).setHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
@@ -693,7 +693,7 @@ public class ConnectionHelper {
}
});
} else {
if (!open_unsafe)
if (open_safe)
throw new IOException("https required url=" + url);
}
@@ -703,7 +703,7 @@ public class ConnectionHelper {
try {
int status = urlConnection.getResponseCode();
if (open_unsafe &&
if (!open_safe &&
(status == HttpURLConnection.HTTP_MOVED_PERM ||
status == HttpURLConnection.HTTP_MOVED_TEMP ||
status == HttpURLConnection.HTTP_SEE_OTHER ||