Set User agent to modern chrome (#5708)

This commit is contained in:
Chris H
2024-07-28 05:56:01 -04:00
committed by GitHub
parent c52ce34f12
commit 5c55d7b001
3 changed files with 11 additions and 13 deletions

View File

@@ -2,15 +2,14 @@ package forge.util;
import forge.localinstance.properties.ForgeConstants;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.SwingUtilities;
public class SwingImageFetcher extends ImageFetcher {
@Override
@@ -75,7 +74,7 @@ public class SwingImageFetcher extends ImageFetcher {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//connection.setConnectTimeout(1000 * 5); //wait 5 seconds the most
//connection.setReadTimeout(1000 * 5);
conn.setRequestProperty("User-Agent", "");
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
if(conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
imageurl = TextUtil.fastReplace(imageurl, ".full.jpg", ".fullborder.jpg");
conn.disconnect();

View File

@@ -1,5 +1,10 @@
package forge.util;
import com.badlogic.gdx.files.FileHandle;
import forge.Forge;
import forge.gui.GuiBase;
import forge.localinstance.properties.ForgeConstants;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -7,12 +12,6 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import com.badlogic.gdx.files.FileHandle;
import forge.Forge;
import forge.gui.GuiBase;
import forge.localinstance.properties.ForgeConstants;
public class LibGDXImageFetcher extends ImageFetcher {
@Override
protected Runnable getDownloadTask(String[] downloadUrls, String destPath, Runnable notifyObservers) {
@@ -38,7 +37,7 @@ public class LibGDXImageFetcher extends ImageFetcher {
URL url = new URL(urlToDownload);
System.out.println("Attempting to fetch: " + url);
java.net.URLConnection c = url.openConnection();
c.setRequestProperty("User-Agent", "");
c.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
InputStream is = c.getInputStream();
// First, save to a temporary file so that nothing tries to read
@@ -65,7 +64,7 @@ public class LibGDXImageFetcher extends ImageFetcher {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
//connection.setConnectTimeout(1000 * 5); //wait 5 seconds the most
//connection.setReadTimeout(1000 * 5);
conn.setRequestProperty("User-Agent", "");
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
if(conn.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
imageurl = TextUtil.fastReplace(imageurl, ".full.jpg", ".fullborder.jpg");
conn.disconnect();

View File

@@ -91,7 +91,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
if (url.getPath().endsWith(".php")) {
//ensure file can be downloaded if returned from PHP script
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)");
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
}
conn.connect();