diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-24 16:41:01 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-24 16:41:01 +0100 |
commit | e573cd774a4a41234c229d9c49ef7a5656445f93 (patch) | |
tree | 3efd104d6d8e1ec4feeaa9ca351cd13cdf3261b4 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java | |
parent | f9ef1160ca764d508dafcb45fbf65f18911fff9c (diff) | |
download | open-keychain-e573cd774a4a41234c229d9c49ef7a5656445f93.tar.gz open-keychain-e573cd774a4a41234c229d9c49ef7a5656445f93.tar.bz2 open-keychain-e573cd774a4a41234c229d9c49ef7a5656445f93.zip |
work on cookie scanning during creation
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java | 49 |
1 files changed, 6 insertions, 43 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java index c6d5883ee..4cf56fe67 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java @@ -8,6 +8,7 @@ import android.support.annotation.StringRes; import com.textuality.keybase.lib.Search; +import org.apache.http.client.methods.HttpGet; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType; @@ -40,53 +41,15 @@ public class GenericHttpsResource extends LinkedCookieResource { } @Override - protected String fetchResource (OperationLog log, int indent) { + protected String fetchResource (OperationLog log, int indent) throws HttpStatusException, IOException { log.add(LogType.MSG_LV_FETCH, indent, mSubUri.toString()); indent += 1; - try { - - HttpsURLConnection conn = null; - URL url = mSubUri.toURL(); - int status = 0; - int redirects = 0; - - while (redirects < 5) { - conn = (HttpsURLConnection) url.openConnection(); - conn.addRequestProperty("User-Agent", "OpenKeychain"); - conn.setConnectTimeout(5000); - conn.setReadTimeout(25000); - conn.connect(); - status = conn.getResponseCode(); - if (status == 301) { - redirects++; - url = new URL(conn.getHeaderFields().get("Location").get(0)); - log.add(LogType.MSG_LV_FETCH_REDIR, indent, url.toString()); - } else { - break; - } - } - - if (status >= 200 && status < 300) { - log.add(LogType.MSG_LV_FETCH_OK, indent, Integer.toString(status)); - return Search.snarf(conn.getInputStream()); - } else { - // log verbose output to logcat - Log.e(Constants.TAG, Search.snarf(conn.getErrorStream())); - log.add(LogType.MSG_LV_FETCH_ERROR, indent, Integer.toString(status)); - return null; - } - - } catch (MalformedURLException e) { - log.add(LogType.MSG_LV_FETCH_ERROR_URL, indent); - return null; - } catch (IOException e) { - Log.e(Constants.TAG, "io error", e); - e.printStackTrace(); - log.add(LogType.MSG_LV_FETCH_ERROR_IO, indent); - return null; - } + HttpGet httpGet = new HttpGet(mSubUri); + return getResponseBody(httpGet); + + // log.add(LogType.MSG_LV_FETCH_REDIR, indent, url.toString()); } |