From 995c26e8225b888d5d65c977edaba71283c3d050 Mon Sep 17 00:00:00 2001 From: Subhas Dandapani Date: Thu, 7 Feb 2013 12:03:47 +0300 Subject: [PATCH] Subhas/Akash | Fix HTTP Connection issues in Android --- .travis.yml | 7 ++++--- RapidFTR-Android/pom.xml | 1 - .../main/java/com/rapidftr/service/FormService.java | 2 +- .../java/com/rapidftr/utils/http/FluentRequest.java | 5 ++++- pom.xml | 10 +++++----- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 199c2fff..e8e97a7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,10 @@ env: - ANDROID_HOME=$HOME/android-sdk-linux - secure: "eATae5kWD2tL3xtUdQjk4T5RWn4zv5OS4QXjwL9q/E4ntzge3rVPRGVSyS5/\nL/d48QLlliDzC6d7ycFVyEZC0OLzpHNER56vhP4YY9yfLygHr+NQJizPEiMJ\nPj5vUu9+qfOb3icQuQYDamuOCT7CxnVXSxVApfpFSSGz1YFpwfs=" matrix: - - ANDROID_SDKS=android-8 ANDROID_TARGET=android-8 ANDROID_ABI=armeabi - - ANDROID_SDKS=android-10 ANDROID_TARGET=android-10 ANDROID_ABI=armeabi - - ANDROID_SDKS=android-17,sysimg-17 ANDROID_TARGET=android-17 ANDROID_ABI=armeabi-v7a +# - ANDROID_SDKS=android-8 ANDROID_TARGET=android-8 ANDROID_ABI=armeabi +# - ANDROID_SDKS=android-10 ANDROID_TARGET=android-10 ANDROID_ABI=armeabi + - ANDROID_SDKS=android-15,sysimg-17 ANDROID_TARGET=android-15 ANDROID_ABI=armeabi-v7a +# - ANDROID_SDKS=android-17,sysimg-17 ANDROID_TARGET=android-17 ANDROID_ABI=armeabi-v7a branches: only: diff --git a/RapidFTR-Android/pom.xml b/RapidFTR-Android/pom.xml index b6955188..fbf60577 100644 --- a/RapidFTR-Android/pom.xml +++ b/RapidFTR-Android/pom.xml @@ -82,7 +82,6 @@ org.apache.httpcomponents httpmime - 4.1.3 diff --git a/RapidFTR-Android/src/main/java/com/rapidftr/service/FormService.java b/RapidFTR-Android/src/main/java/com/rapidftr/service/FormService.java index 8b65bad4..59ee0a57 100644 --- a/RapidFTR-Android/src/main/java/com/rapidftr/service/FormService.java +++ b/RapidFTR-Android/src/main/java/com/rapidftr/service/FormService.java @@ -22,8 +22,8 @@ public FormService(RapidFtrApplication context) { public void getPublishedFormSections() throws IOException { FluentResponse formSectionsResponse = http() - .path("/published_form_sections") .context(context) + .path("/published_form_sections") .get(); if (formSectionsResponse.isSuccess()) { diff --git a/RapidFTR-Android/src/main/java/com/rapidftr/utils/http/FluentRequest.java b/RapidFTR-Android/src/main/java/com/rapidftr/utils/http/FluentRequest.java index 7e90a9aa..7546457a 100644 --- a/RapidFTR-Android/src/main/java/com/rapidftr/utils/http/FluentRequest.java +++ b/RapidFTR-Android/src/main/java/com/rapidftr/utils/http/FluentRequest.java @@ -23,6 +23,7 @@ import org.apache.http.entity.mime.content.ByteArrayBody; import org.apache.http.entity.mime.content.StringBody; import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.conn.SingleClientConnManager; import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.http.message.BasicNameValuePair; import org.apache.http.params.BasicHttpParams; @@ -61,6 +62,8 @@ public FluentRequest host(String host) { String[] parts = host.split("\\:\\/\\/"); scheme(parts[0]); host = parts[1]; + } else { + scheme("http"); } uri.encodedAuthority(host); @@ -228,7 +231,7 @@ private static HttpClient createHttpClient() { registry.register(new Scheme("https", new SelfSignedSSLSocketFactory(trusted), 443)); HttpParams params = new BasicHttpParams(); - ClientConnectionManager connectionManager = new ThreadSafeClientConnManager(params, registry); + ClientConnectionManager connectionManager = new SingleClientConnManager(params, registry); return new DefaultHttpClient(connectionManager, params); } catch (Exception e) { diff --git a/pom.xml b/pom.xml index e5330101..9a0064b9 100644 --- a/pom.xml +++ b/pom.xml @@ -91,11 +91,6 @@ crittercism 3.0.3 - - org.apache.james - apache-mime4j - 0.7.2 - com.google.android support-v4 @@ -170,6 +165,11 @@ commons-codec 1.0 + + org.apache.httpcomponents + httpmime + 4.2 +