aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-02-09 17:20:31 -0800
committerScott Jackson <daneren2005@gmail.com>2016-02-09 17:20:31 -0800
commitc991a5db04792ad00cb6b1282d378c810dd297df (patch)
tree08cf895e8892560b7b5007f1be5adbfed7b918a7 /app/src/main/java/github
parent743a723474f07f5daa8d75605713bd12efffed51 (diff)
downloaddsub-c991a5db04792ad00cb6b1282d378c810dd297df.tar.gz
dsub-c991a5db04792ad00cb6b1282d378c810dd297df.tar.bz2
dsub-c991a5db04792ad00cb6b1282d378c810dd297df.zip
Fixed #644: Older versions of Android require connection open when parsing response
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
index 65ed99b9..f3d675f0 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/MainFragment.java
@@ -298,6 +298,7 @@ public class MainFragment extends SelectRecyclerFragment<Integer> {
URL url = new URL("https://pastebin.com/api/api_post.php");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
+ StringBuffer responseBuffer = new StringBuffer();
try {
urlConnection.setReadTimeout(10000);
urlConnection.setConnectTimeout(15000);
@@ -339,18 +340,17 @@ public class MainFragment extends SelectRecyclerFragment<Integer> {
writer.flush();
writer.close();
os.close();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
+ String inputLine;
+ while ((inputLine = in.readLine()) != null) {
+ responseBuffer.append(inputLine);
+ }
+ in.close();
} finally {
urlConnection.disconnect();
}
- BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
- String inputLine;
- StringBuffer responseBuffer = new StringBuffer();
- while ((inputLine = in.readLine()) != null) {
- responseBuffer.append(inputLine);
- }
- in.close();
-
String response = responseBuffer.toString();
if(response.indexOf("http") == 0) {
return response.replace("http:", "https:");
@@ -361,6 +361,7 @@ public class MainFragment extends SelectRecyclerFragment<Integer> {
@Override
protected void error(Throwable error) {
+ Log.e(TAG, "Failed to gather logs", error);
Util.toast(context, "Failed to gather logs");
}