mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 03:46:00 +01:00
Refactoring
This commit is contained in:
@@ -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 ||
|
||||
|
||||
Reference in New Issue
Block a user