mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-01 22:14:01 +03:00
small fix user agent
This commit is contained in:
parent
8bec134611
commit
a1fdc4cc39
3 changed files with 6 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -27,7 +28,7 @@ public static JsonElement jsonRequest(JsonElement request, String method, URL ur
|
|||
if (request != null) connection.setDoOutput(true);
|
||||
connection.setRequestMethod(method);
|
||||
if (request != null) connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
|
||||
if (request != null) connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36");
|
||||
if (request != null) connection.setRequestProperty("User-Agent", IOHelper.USER_AGENT);
|
||||
connection.setRequestProperty("Accept", "application/json");
|
||||
if (TIMEOUT > 0)
|
||||
connection.setConnectTimeout(TIMEOUT);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package pro.gravit.utils.helper;
|
||||
|
||||
import pro.gravit.utils.Version;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageReader;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
@ -43,7 +45,7 @@ public final class IOHelper {
|
|||
public static final Path JVM_DIR = Paths.get(System.getProperty("java.home"));
|
||||
public static final Path HOME_DIR = Paths.get(System.getProperty("user.home"));
|
||||
public static final Path WORKING_DIR = Paths.get(System.getProperty("user.dir"));
|
||||
public static final String USER_AGENT = System.getProperty("launcher.userAgentDefault", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
|
||||
public static final String USER_AGENT = System.getProperty("launcher.userAgentDefault", String.format("GravitLauncher/%s", Version.getVersion()));
|
||||
// Open options - as arrays
|
||||
private static final OpenOption[] READ_OPTIONS = {StandardOpenOption.READ};
|
||||
private static final OpenOption[] WRITE_OPTIONS = {StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING};
|
||||
|
|
|
@ -39,7 +39,7 @@ public static JsonElement jsonRequest(JsonElement request, String method, URL ur
|
|||
.uri(url.toURI())
|
||||
.header("Content-Type", "application/json; charset=UTF-8")
|
||||
.header("Accept", "application/json")
|
||||
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36")
|
||||
.header("User-Agent", IOHelper.USER_AGENT)
|
||||
.timeout(Duration.ofMillis(TIMEOUT))
|
||||
.build();
|
||||
HttpResponse<InputStream> response = client.send(request1, HttpResponse.BodyHandlers.ofInputStream());
|
||||
|
|
Loading…
Reference in a new issue