Check http response code

pull/199/head
M66B 3 years ago
parent 487b1038c0
commit 3b82c631db

@ -601,6 +601,10 @@ public class ContactInfo {
connection.connect();
try {
int status = connection.getResponseCode();
if (status != HttpURLConnection.HTTP_OK)
throw new FileNotFoundException("Error " + status + ":" + connection.getResponseMessage());
Bitmap bitmap = ImageHelper.getScaledBitmap(connection.getInputStream(), url.toString(), scaleToPixels);
if (bitmap == null)
throw new FileNotFoundException("decodeStream");

@ -30,6 +30,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
@ -120,6 +121,10 @@ public class DisconnectBlacklist {
connection.connect();
try {
int status = connection.getResponseCode();
if (status != HttpsURLConnection.HTTP_OK)
throw new FileNotFoundException("Error " + status + ":" + connection.getResponseMessage());
String response = Helper.readStream(connection.getInputStream());
Helper.writeText(file, response);
} finally {

@ -355,6 +355,10 @@ public class EmailProvider {
request.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context));
request.connect();
int status = request.getResponseCode();
if (status != HttpURLConnection.HTTP_OK)
throw new FileNotFoundException("Error " + status + ":" + request.getResponseMessage());
// https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser xml = factory.newPullParser();

@ -7771,6 +7771,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
connection.connect();
try {
int status = connection.getResponseCode();
if (status != HttpURLConnection.HTTP_OK)
throw new FileNotFoundException("Error " + status + ":" + connection.getResponseMessage());
Helper.copy(connection.getInputStream(), os);
} finally {
connection.disconnect();

@ -70,6 +70,7 @@ import net.openid.appauth.browser.VersionedBrowserMatcher;
import org.json.JSONObject;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
@ -483,6 +484,10 @@ public class FragmentOAuth extends FragmentBase {
connection.connect();
try {
int status = connection.getResponseCode();
if (status != HttpsURLConnection.HTTP_OK)
throw new FileNotFoundException("Error " + status + ":" + connection.getResponseMessage());
String json = Helper.readStream(connection.getInputStream());
Log.i("json=" + json);
JSONObject data = new JSONObject(json);

@ -27,6 +27,7 @@ import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.core.net.MailTo;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URL;
@ -79,6 +80,10 @@ public class IPInfo {
Organization organization = new Organization();
try {
int status = connection.getResponseCode();
if (status != HttpsURLConnection.HTTP_OK)
throw new FileNotFoundException("Error " + status + ":" + connection.getResponseMessage());
String response = Helper.readStream(connection.getInputStream());
organization.name = response.trim();
if ("".equals(organization.name) || "undefined".equals(organization.name))

Loading…
Cancel
Save