aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--settings.gradle10
-rw-r--r--spark-common/build.gradle3
-rw-r--r--spark-common/src/main/java/me/lucko/spark/util/BytebinClient.java54
3 files changed, 12 insertions, 55 deletions
diff --git a/settings.gradle b/settings.gradle
index f94c60b..908e607 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,2 +1,10 @@
rootProject.name = 'spark'
-include 'spark-common', 'spark-bukkit', 'spark-bungeecord', 'spark-velocity', 'spark-sponge', 'spark-universal', 'spark-forge' \ No newline at end of file
+include (
+ 'spark-common',
+ 'spark-bukkit',
+ 'spark-bungeecord',
+ 'spark-velocity',
+ 'spark-sponge',
+ 'spark-forge',
+ 'spark-universal'
+)
diff --git a/spark-common/build.gradle b/spark-common/build.gradle
index 453bbdd..60dbf0c 100644
--- a/spark-common/build.gradle
+++ b/spark-common/build.gradle
@@ -1,5 +1,6 @@
dependencies {
- compile 'com.squareup.okhttp3:okhttp:3.10.0'
+ compile 'com.squareup.okhttp3:okhttp:3.12.0'
+ compile 'com.squareup.okio:okio:1.16.0'
compileOnly 'com.google.code.gson:gson:2.7'
compileOnly 'com.google.guava:guava:19.0'
}
diff --git a/spark-common/src/main/java/me/lucko/spark/util/BytebinClient.java b/spark-common/src/main/java/me/lucko/spark/util/BytebinClient.java
index 01f63f7..00e1c69 100644
--- a/spark-common/src/main/java/me/lucko/spark/util/BytebinClient.java
+++ b/spark-common/src/main/java/me/lucko/spark/util/BytebinClient.java
@@ -31,12 +31,6 @@ import okhttp3.RequestBody;
import okhttp3.Response;
import java.io.IOException;
-import java.net.Proxy;
-import java.net.ProxySelector;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.util.Collections;
-import java.util.List;
/**
* Utility for posting content to bytebin.
@@ -63,31 +57,7 @@ public class BytebinClient {
this.url = url + "/post";
}
this.userAgent = userAgent;
- this.okHttp = new OkHttpClient.Builder()
- .proxySelector(new NullSafeProxySelector())
- .build();
- }
-
- /**
- * Posts content to bytebin.
- *
- * @param buf the content
- * @param contentType the type of the content
- * @return the key of the resultant content
- * @throws IOException if an error occurs
- */
- public String postContent(byte[] buf, MediaType contentType) throws IOException {
- RequestBody body = RequestBody.create(contentType, buf);
-
- Request.Builder requestBuilder = new Request.Builder()
- .header("User-Agent", this.userAgent)
- .url(this.url)
- .post(body);
-
- Request request = requestBuilder.build();
- try (Response response = makeHttpRequest(request)) {
- return response.header("Location");
- }
+ this.okHttp = new OkHttpClient();
}
/**
@@ -120,26 +90,4 @@ public class BytebinClient {
}
return response;
}
-
- // sometimes ProxySelector#getDefault returns null, and okhttp doesn't like that
- private static final class NullSafeProxySelector extends ProxySelector {
- private static final List<Proxy> DIRECT = Collections.singletonList(Proxy.NO_PROXY);
-
- @Override
- public List<Proxy> select(URI uri) {
- ProxySelector def = ProxySelector.getDefault();
- if (def == null) {
- return DIRECT;
- }
- return def.select(uri);
- }
-
- @Override
- public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
- ProxySelector def = ProxySelector.getDefault();
- if (def != null) {
- def.connectFailed(uri, sa, ioe);
- }
- }
- }
}