fix: add locale to avoid wrong yggdrasil server name (#2521)

* fix: add locale to avoid wrong yggdrasil server name

* update

---------

Co-authored-by: Glavo <zjx001202@gmail.com>
This commit is contained in:
Myth 2024-03-23 14:19:16 +08:00 committed by GitHub
parent 94ccee0b76
commit 1605eb1775
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -60,6 +60,7 @@ public class AuthlibInjectorServer implements Observable {
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 class AuthlibInjectorServer implements Observable {
conn.disconnect();
url = absoluteAli.toString();
conn = (HttpURLConnection) absoluteAli.openConnection();
conn.setRequestProperty("Accept-Language", Locale.getDefault().toLanguageTag());
}
}

View File

@ -90,7 +90,7 @@ public final class NetworkUtils {
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;
}