Skip to content

Commit

Permalink
fix: add locale to avoid wrong yggdrasil server name (#2521)
Browse files Browse the repository at this point in the history
* fix: add locale to avoid wrong yggdrasil server name

* update

---------

Co-authored-by: Glavo <zjx001202@gmail.com>
  • Loading branch information
Mythologyli and Glavo committed Mar 23, 2024
1 parent 94ccee0 commit 1605eb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Expand Up @@ -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) {
Expand All @@ -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());
}
}

Expand Down
Expand Up @@ -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;
}

Expand Down

0 comments on commit 1605eb1

Please sign in to comment.