Skip to content

Instantly share code, notes, and snippets.

@clubapplets-server
Created March 2, 2019 20:20
Show Gist options
  • Save clubapplets-server/180f1b6cc97c6bce1f2ea10dbd30e0ee to your computer and use it in GitHub Desktop.
Save clubapplets-server/180f1b6cc97c6bce1f2ea10dbd30e0ee to your computer and use it in GitHub Desktop.
Update OkHttp to 3.12.1 for J2SE module in KSoap2-Android
From c9acff6f900646eed514cbd968e796b17bf1622b Mon Sep 17 00:00:00 2001
From: zaclimon <isaacpateau05@gmail.com>
Date: Sat, 2 Mar 2019 14:29:01 -0500
Subject: [PATCH 1/1] Update OkHttp
In order to use KSoap-Android with other apps that might use
a more recent of OkHttp, do the following
- J2SE: Update OkHttp from 3.2.0 to 3.12.0
- OkHttp: Update from 3.2.0 to 3.12.1
- J2SE: Replace HttpURLConnectionImpl by OkHttpUrlConnection in
OkHttpService
---
ksoap2-j2se/pom.xml | 2 +-
.../ksoap2/transport/OkHttpServiceConnectionSE.java | 13 ++++---------
ksoap2-okhttp/pom.xml | 2 +-
3 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/ksoap2-j2se/pom.xml b/ksoap2-j2se/pom.xml
index 3bd2831..84ac090 100644
--- a/ksoap2-j2se/pom.xml
+++ b/ksoap2-j2se/pom.xml
@@ -33,7 +33,7 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp-urlconnection</artifactId>
- <version>3.2.0</version>
+ <version>3.12.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
diff --git a/ksoap2-j2se/src/main/java/org/ksoap2/transport/OkHttpServiceConnectionSE.java b/ksoap2-j2se/src/main/java/org/ksoap2/transport/OkHttpServiceConnectionSE.java
index 225d5fc..f7946fd 100644
--- a/ksoap2-j2se/src/main/java/org/ksoap2/transport/OkHttpServiceConnectionSE.java
+++ b/ksoap2-j2se/src/main/java/org/ksoap2/transport/OkHttpServiceConnectionSE.java
@@ -1,5 +1,7 @@
package org.ksoap2.transport;
+import okhttp3.OkHttpClient;
+import okhttp3.internal.huc.OkHttpURLConnection;
import org.ksoap2.HeaderProperty;
import java.io.IOException;
@@ -8,16 +10,9 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.TimeUnit;
-import okhttp3.OkHttpClient;
-import okhttp3.internal.huc.HttpURLConnectionImpl;
-
/**
* A simple ServiceConnection based on OkHttp3's URLConnection implementation
* as a workaround for Android's timeout issues
@@ -60,7 +55,7 @@ public class OkHttpServiceConnectionSE implements ServiceConnection {
public OkHttpServiceConnectionSE(OkHttpClient client, Proxy proxy, String url, int timeout) throws IOException {
this.client = client;
- connection = new HttpURLConnectionImpl(new URL(url), client);
+ connection = new OkHttpURLConnection(new URL(url), client);
// connection = (proxy == null)
// ? new HttpURLConnectionImpl(new URL(url), client)
// : (HttpURLConnectionImpl) new URL(url).openConnection(proxy);
diff --git a/ksoap2-okhttp/pom.xml b/ksoap2-okhttp/pom.xml
index 02901c9..c145ddb 100644
--- a/ksoap2-okhttp/pom.xml
+++ b/ksoap2-okhttp/pom.xml
@@ -19,7 +19,7 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp-urlconnection</artifactId>
- <version>3.12.0</version>
+ <version>3.12.1</version>
</dependency>
<dependency>
<groupId>jcifs</groupId>
--
2.20.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment