aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2023-01-28 17:21:42 +0000
committerLuck <git@lucko.me>2023-01-28 17:21:42 +0000
commitf5fd47e225b5e887ea7fbccf5bfa5a927be35619 (patch)
treefd216089637431908b860ef92b54ea8baf436a94
parent06b794dcea806150770fb88d43e366a3496a9d0f (diff)
downloadspark-f5fd47e225b5e887ea7fbccf5bfa5a927be35619.tar.gz
spark-f5fd47e225b5e887ea7fbccf5bfa5a927be35619.tar.bz2
spark-f5fd47e225b5e887ea7fbccf5bfa5a927be35619.zip
Fix bytebin user agent
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java b/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
index 8f11edc..b8a2053 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/util/BytebinClient.java
@@ -47,7 +47,11 @@ public class BytebinClient {
this.userAgent = userAgent;
}
- private Content postContent(String contentType, Consumer<OutputStream> consumer, String userAgent) throws IOException {
+ private Content postContent(String contentType, Consumer<OutputStream> consumer, String userAgentExtra) throws IOException {
+ String userAgent = userAgentExtra != null
+ ? this.userAgent + "/" + userAgentExtra
+ : this.userAgent;
+
URL url = new URL(this.url + "post");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
try {
@@ -83,11 +87,11 @@ public class BytebinClient {
} catch (IOException e) {
throw new RuntimeException(e);
}
- }, this.userAgent + "/" + userAgentExtra);
+ }, userAgentExtra);
}
public Content postContent(AbstractMessageLite<?, ?> proto, String contentType) throws IOException {
- return postContent(proto, contentType, this.userAgent);
+ return postContent(proto, contentType, null);
}
public static final class Content {