Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #620 PR2 break dependency on httpclient and replace with okhttp3 #2595

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
13be0cf
Update README.md
xsteelej Apr 11, 2018
c4649bd
Merge remote-tracking branch 'upstream/master'
xsteelej Apr 19, 2018
370165e
Merge remote-tracking branch 'upstream/master'
xsteelej Apr 21, 2018
531c064
Merge remote-tracking branch 'upstream/master'
jrsteele09 May 3, 2018
7a4ab5d
Merge remote-tracking branch 'upstream/master'
jrsteele09 May 21, 2018
81792b7
Merge remote-tracking branch 'upstream/master'
jrsteele09 May 29, 2018
a984954
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jun 14, 2018
1f9fb24
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jun 25, 2018
d83977b
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jun 26, 2018
a45f551
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jun 30, 2018
0cb2f3f
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jul 16, 2018
0daebc5
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jul 17, 2018
ccd5944
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jul 20, 2018
cd834ab
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jul 23, 2018
01bb430
Merge remote-tracking branch 'upstream/master'
jrsteele09 Jul 31, 2018
46d72f2
Merge remote-tracking branch 'upstream/master'
jrsteele09 Aug 6, 2018
1eaca08
Merge remote-tracking branch 'upstream/master'
jrsteele09 Aug 13, 2018
03fa178
Merge remote-tracking branch 'upstream/master'
jrsteele09 Aug 20, 2018
c0949af
Merge remote-tracking branch 'upstream/master'
jrsteele09 Aug 26, 2018
eff64be
Merge remote-tracking branch 'upstream/master'
jrsteele09 Aug 28, 2018
aa40f4a
Merge remote-tracking branch 'upstream/master'
jrsteele09 Sep 5, 2018
2a9df87
Merge remote-tracking branch 'upstream/master'
jrsteele09 Sep 6, 2018
e615e7f
Added okhttp3 to the project and created a new OkHttpConnection which…
jrsteele09 Sep 6, 2018
0f6a918
Re-added mockwebserver to re-enable the AndroidTest suite.
jrsteele09 Sep 6, 2018
0eadcfd
Merge remote-tracking branch 'upstream/master'
jrsteele09 Sep 10, 2018
1477c83
Merge branch 'master' into issue_#620_PR2_break_dependency_on_httpclient
jrsteele09 Sep 10, 2018
59f4ae8
Merge remote-tracking branch 'upstream/master'
jrsteele09 Sep 14, 2018
e272ecd
Merge branch 'master' into issue_#620_PR2_break_dependency_on_httpclient
jrsteele09 Sep 14, 2018
cf18499
Merge remote-tracking branch 'upstream/master'
jrsteele09 Sep 17, 2018
ca96ccf
Merge remote-tracking branch 'upstream/master'
jrsteele09 Sep 20, 2018
3d9fe4b
Merge branch 'master' into issue_#620_PR2_break_dependency_on_httpclient
jrsteele09 Sep 20, 2018
1196e10
Added okhttp-digest to the Project and modified OkHttpConnection to a…
jrsteele09 Sep 24, 2018
4c286b6
Fixed androidTests that were broken due to the change over to http3
jrsteele09 Sep 25, 2018
9051ce1
Removed HttpClientConnection and modified the tests to work with OkHt…
jrsteele09 Sep 26, 2018
aef3d84
Merge remote-tracking branch 'upstream/master'
jrsteele09 Sep 30, 2018
5801da8
Merge branch 'master' into issue_#620_PR2_break_dependency_on_httpclient
jrsteele09 Sep 30, 2018
550d6fc
Fixed a PMD error
jrsteele09 Sep 30, 2018
bcfb028
- The version of okhttp3 used in the project is now a variable (Same …
jrsteele09 Oct 9, 2018
5758c4c
Check Style and PMD error fixes.
jrsteele09 Oct 9, 2018
f4dddf5
Fix for a "Dodgy Code Warning!" from spotbugs - Simplified the code.
jrsteele09 Oct 9, 2018
f2c47f4
Removed the httpclient library + gradle dependencies include line.
jrsteele09 Oct 11, 2018
782914d
Removed the redundant check for headers.size being 0
jrsteele09 Oct 11, 2018
f1a45b8
Renamed httpInterface.get to executeGetRequest and httpInterface.head…
jrsteele09 Oct 11, 2018
d8b08da
Removed the unnecessary catch statements + reordered the statements.
jrsteele09 Oct 11, 2018
a1ff5ec
Updated tests
jrsteele09 Oct 11, 2018
f7494e7
Merge remote-tracking branch 'upstream/master'
jrsteele09 Oct 13, 2018
b8115b4
Merge branch 'master' into issue_#620_PR2_break_dependency_on_httpclient
jrsteele09 Oct 14, 2018
b885fc1
As per review comment, removed try-catch block as it didn't really ad…
jrsteele09 Oct 15, 2018
13135c5
Separated the functionality in ResponseMessageParser, the XML parsing…
jrsteele09 Oct 15, 2018
743e3c1
Added executePostRequest() to MockHttpClientConnection
jrsteele09 Oct 15, 2018
d8dbb3c
PMD Error resolution
jrsteele09 Oct 15, 2018
50a53a6
- Renamed method getRequest, headRequest, postRequest to prepend them…
jrsteele09 Oct 18, 2018
48f93c8
Fixed PMD errors
jrsteele09 Oct 23, 2018
e49d368
Merge remote-tracking branch 'upstream/master'
jrsteele09 Oct 24, 2018
eeb23e2
Merge branch 'master' into issue_#620_PR2_break_dependency_on_httpcli…
jrsteele09 Oct 25, 2018
20432fa
Fixed PMD errors
jrsteele09 Oct 25, 2018
015d95c
Renamed isEqualTo to the standard Java equal
steelej-arm Nov 7, 2018
8a557ec
* Refactored of OkHttpClientConnection to cleanup the code that creat…
steelej-arm Nov 11, 2018
8d757f9
Merge remote-tracking branch 'upstream/master'
jrsteele09 Nov 12, 2018
d3b30ef
Merge branch 'master' into issue_#620_PR2_break_dependency_on_httpclient
jrsteele09 Nov 12, 2018
2088ecf
Modified the HttpCredentials equals() methods to call username and pa…
steelej-arm Nov 19, 2018
ec89657
Fixed checkCode errors.
steelej-arm Nov 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ ext {
leakyCanaryVersion = '1.5.4'
daggerVersion = '2.16'
rxLifecycleVersion = '2.2.1'
okhttp3Version = '3.11.0'
workManagerVersion = "1.0.0-alpha10"
}
7 changes: 5 additions & 2 deletions collect_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ allprojects {
}

dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation "com.android.support:support-v13:${rootProject.supportLibraryVersion}"
implementation "com.android.support:customtabs:${rootProject.supportLibraryVersion}"
implementation "com.android.support:design:${rootProject.supportLibraryVersion}"
Expand Down Expand Up @@ -212,6 +211,10 @@ dependencies {
exclude group: 'org.apache.httpcomponents'
}


implementation "com.squareup.okhttp3:okhttp:${rootProject.okhttp3Version}"
implementation 'com.burgstaller:okhttp-digest:1.18'

implementation 'bikramsambat:bikram-sambat:1.0.0'
implementation "com.evernote:android-job:1.2.5"
implementation "com.rarepebble:colorpicker:2.3.1"
Expand Down Expand Up @@ -317,7 +320,7 @@ dependencies {
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}

androidTestImplementation "com.squareup.okhttp3:mockwebserver:3.9.0"
androidTestImplementation "com.squareup.okhttp3:mockwebserver:${rootProject.okhttp3Version}"

androidTestImplementation "android.arch.work:work-testing:${rootProject.workManagerVersion}"
}
Expand Down
Binary file removed collect_app/libs/httpclientandroidlib-4.5.2-2.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.odk.collect.android.http.CollectServerClient;
import org.odk.collect.android.http.HttpClientConnection;
import org.odk.collect.android.http.HttpGetResult;
import org.odk.collect.android.http.OkHttpConnection;
import org.odk.collect.android.utilities.WebCredentialsUtils;

import java.io.BufferedReader;
Expand Down Expand Up @@ -35,7 +35,7 @@ public class SNITest {

@Test
public void testThatHttpClientSupportsSNI() throws Exception {
CollectServerClient serverClient = new CollectServerClient(new HttpClientConnection(), new WebCredentialsUtils());
CollectServerClient serverClient = new CollectServerClient(new OkHttpConnection(), new WebCredentialsUtils());
HttpGetResult inputStreamResult = serverClient.getHttpInputStream(SNI_URI, null);
assertHttpSuccess(inputStreamResult.getStatusCode());
assertPageContent(inputStreamResult.getInputStream());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ public void shouldProcessAndReturnAFormList() throws Exception {
final Map<String, FormDetails> fetched = new DownloadFormListTask().doInBackground();

// then
RecordedRequest r = nextRequest();
assertEquals("GET", r.getMethod());
assertEquals("/formList", r.getPath());
assertMatches("Dalvik/.* org.odk.collect.android/.*", r.getHeader("User-Agent"));
assertEquals("1.0", r.getHeader("X-OpenRosa-Version"));
assertEquals("gzip", r.getHeader("Accept-Encoding"));
RecordedRequest recordedRequest = nextRequest();
assertEquals("GET", recordedRequest.getMethod());
assertMatches(".*/formList", recordedRequest.getPath());
assertMatches("Dalvik/.* org.odk.collect.android/.*", recordedRequest.getHeader("User-Agent"));
assertEquals("1.0", recordedRequest.getHeader("X-OpenRosa-Version"));
assertEquals("gzip,deflate", recordedRequest.getHeader("Accept-Encoding"));

// and
assertEquals(2, fetched.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.junit.Before;
import org.junit.Test;
import org.odk.collect.android.http.CollectServerClient;
import org.odk.collect.android.http.HttpClientConnection;
import org.odk.collect.android.http.OkHttpConnection;
import org.odk.collect.android.test.MockedServerTest;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.RecordedRequest;
Expand All @@ -21,19 +21,19 @@ public class CollectServerClientTest extends MockedServerTest {
public void setUp() throws Exception {
// server hangs without a response queued:
server.enqueue(new MockResponse());
collectServerClient = new CollectServerClient(new HttpClientConnection(), new WebCredentialsUtils());
collectServerClient = new CollectServerClient(new OkHttpConnection(), new WebCredentialsUtils());
}

@Test
public void httpRequests_shouldHaveUseragentHeader() throws Exception {
// when
doRequest(url("/some-path"));
@Test
public void httpRequests_shouldHaveUserAgentHeader() throws Exception {
// when
doRequest(url("/some-path"));

// then
RecordedRequest r = nextRequest();
assertEquals("GET /some-path HTTP/1.1", r.getRequestLine());
assertTrue(r.getHeader("User-Agent").matches("Dalvik/.* org.odk.collect.android/.*"));
}
// then
RecordedRequest recordedRequest = nextRequest();
assertEquals("GET /some-path HTTP/1.1", recordedRequest.getRequestLine());
assertTrue(recordedRequest.getHeader("User-Agent").matches("Dalvik/.* org.odk.collect.android/.*"));
}

@Test
public void getXmlDocument_request_shouldSupplyHeader_UserAgent() throws Exception {
Expand Down Expand Up @@ -62,7 +62,7 @@ public void getXmlDocument_request_shouldSupplyHeader_AcceptEncoding_gzip() thro
collectServerClient.getXmlDocument(url("/list-forms"));

// then
assertEquals("gzip",
assertEquals("gzip,deflate",
nextRequest().getHeader("Accept-Encoding"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ HttpGetResult getHttpInputStream(@NonNull String downloadUrl, @Nullable final St
throw new Exception("Invalid server URL (no hostname): " + downloadUrl);
}

return httpInterface.get(uri, contentType, webCredentialsUtils.getCredentials(uri));
return httpInterface.executeGetRequest(uri, contentType, webCredentialsUtils.getCredentials(uri));
}

public static String getPlainTextMimeType() {
Expand Down
Loading