From 1605eb177555b7b773e1601586e8a216dcba4ca2 Mon Sep 17 00:00:00 2001 From: Myth Date: Sat, 23 Mar 2024 14:19:16 +0800 Subject: [PATCH] fix: add locale to avoid wrong yggdrasil server name (#2521) * fix: add locale to avoid wrong yggdrasil server name * update --------- Co-authored-by: Glavo --- .../hmcl/auth/authlibinjector/AuthlibInjectorServer.java | 2 ++ .../src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorServer.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorServer.java index f5102cbe53..d547a73879 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorServer.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/authlibinjector/AuthlibInjectorServer.java @@ -60,6 +60,7 @@ public static AuthlibInjectorServer locateServer(String url) throws IOException try { url = addHttpsIfMissing(url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); + conn.setRequestProperty("Accept-Language", Locale.getDefault().toLanguageTag()); String ali = conn.getHeaderField("x-authlib-injector-api-location"); if (ali != null) { @@ -68,6 +69,7 @@ public static AuthlibInjectorServer locateServer(String url) throws IOException conn.disconnect(); url = absoluteAli.toString(); conn = (HttpURLConnection) absoluteAli.openConnection(); + conn.setRequestProperty("Accept-Language", Locale.getDefault().toLanguageTag()); } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java index afd352dbe4..706dde7734 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java @@ -90,7 +90,7 @@ public static URLConnection createConnection(URL url) throws IOException { connection.setUseCaches(false); connection.setConnectTimeout(TIME_OUT); connection.setReadTimeout(TIME_OUT); - connection.setRequestProperty("Accept-Language", Locale.getDefault().toString()); + connection.setRequestProperty("Accept-Language", Locale.getDefault().toLanguageTag()); return connection; }