mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Declare Forge user agent (#5946)
This commit is contained in:
@@ -45,4 +45,8 @@ public class BuildInfo {
|
|||||||
return StringUtils.containsIgnoreCase(forgeVersion, "git") ||
|
return StringUtils.containsIgnoreCase(forgeVersion, "git") ||
|
||||||
StringUtils.containsIgnoreCase(forgeVersion, "snapshot");
|
StringUtils.containsIgnoreCase(forgeVersion, "snapshot");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getUserAgent() {
|
||||||
|
return "Forge/" + getVersionString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class SwingImageFetcher extends ImageFetcher {
|
|||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
//connection.setConnectTimeout(1000 * 5); //wait 5 seconds the most
|
//connection.setConnectTimeout(1000 * 5); //wait 5 seconds the most
|
||||||
//connection.setReadTimeout(1000 * 5);
|
//connection.setReadTimeout(1000 * 5);
|
||||||
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
|
conn.setRequestProperty("User-Agent", BuildInfo.getUserAgent());
|
||||||
if(conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
|
if(conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
|
||||||
imageurl = TextUtil.fastReplace(imageurl, ".full.jpg", ".fullborder.jpg");
|
imageurl = TextUtil.fastReplace(imageurl, ".full.jpg", ".fullborder.jpg");
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LibGDXImageFetcher extends ImageFetcher {
|
|||||||
URL url = new URL(urlToDownload);
|
URL url = new URL(urlToDownload);
|
||||||
System.out.println("Attempting to fetch: " + url);
|
System.out.println("Attempting to fetch: " + url);
|
||||||
java.net.URLConnection c = url.openConnection();
|
java.net.URLConnection c = url.openConnection();
|
||||||
c.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
|
c.setRequestProperty("User-Agent", BuildInfo.getUserAgent());
|
||||||
|
|
||||||
InputStream is = c.getInputStream();
|
InputStream is = c.getInputStream();
|
||||||
// First, save to a temporary file so that nothing tries to read
|
// First, save to a temporary file so that nothing tries to read
|
||||||
@@ -64,7 +64,7 @@ public class LibGDXImageFetcher extends ImageFetcher {
|
|||||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
//connection.setConnectTimeout(1000 * 5); //wait 5 seconds the most
|
//connection.setConnectTimeout(1000 * 5); //wait 5 seconds the most
|
||||||
//connection.setReadTimeout(1000 * 5);
|
//connection.setReadTimeout(1000 * 5);
|
||||||
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
|
conn.setRequestProperty("User-Agent", BuildInfo.getUserAgent());
|
||||||
if(conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
|
if(conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
|
||||||
imageurl = TextUtil.fastReplace(imageurl, ".full.jpg", ".fullborder.jpg");
|
imageurl = TextUtil.fastReplace(imageurl, ".full.jpg", ".fullborder.jpg");
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.google.common.io.Files;
|
|||||||
import forge.gui.FThreads;
|
import forge.gui.FThreads;
|
||||||
import forge.gui.GuiBase;
|
import forge.gui.GuiBase;
|
||||||
import forge.gui.interfaces.IProgressBar;
|
import forge.gui.interfaces.IProgressBar;
|
||||||
|
import forge.util.BuildInfo;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -89,7 +90,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
|||||||
|
|
||||||
if (url.getPath().endsWith(".php")) {
|
if (url.getPath().endsWith(".php")) {
|
||||||
//ensure file can be downloaded if returned from PHP script
|
//ensure file can be downloaded if returned from PHP script
|
||||||
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
|
conn.setRequestProperty("User-Agent", BuildInfo.getUserAgent());
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|||||||
Reference in New Issue
Block a user