From f5fd47e225b5e887ea7fbccf5bfa5a927be35619 Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 28 Jan 2023 17:21:42 +0000 Subject: Fix bytebin user agent --- .../main/java/me/lucko/spark/common/util/BytebinClient.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'spark-common/src/main/java/me/lucko/spark') 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 consumer, String userAgent) throws IOException { + private Content postContent(String contentType, Consumer 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 { -- cgit