download: reworked connection:

- added shareable code with default proxy, headers and other settings for download tasks like images, symbols, mtgjson, etc;
- use XmageURLConnection.downloadText for text resources
- use XmageURLConnection.downloadBinary for any file resources
- added user agent with app version for all requests;
- added http logs and improved error messages;
This commit is contained in:
Oleg Agafonov 2024-07-31 16:24:59 +04:00
parent fad63389d0
commit e1cffbde40
35 changed files with 713 additions and 464 deletions

View file

@ -32,7 +32,7 @@ import mage.target.TargetCard;
import mage.util.CardUtil;
import mage.util.RandomUtil;
import mage.util.ThreadUtils;
import mage.util.XMageThreadFactory;
import mage.util.XmageThreadFactory;
import org.apache.log4j.Logger;
import java.util.*;
@ -61,7 +61,7 @@ public class ComputerPlayer6 extends ComputerPlayer {
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(),
new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_AI_SIMULATION_MAD)
new XmageThreadFactory(ThreadUtils.THREAD_PREFIX_AI_SIMULATION_MAD)
);
protected int maxDepth;
protected int maxNodes;

View file

@ -13,7 +13,7 @@ import mage.game.combat.CombatGroup;
import mage.player.ai.MCTSPlayer.NextAction;
import mage.players.Player;
import mage.util.ThreadUtils;
import mage.util.XMageThreadFactory;
import mage.util.XmageThreadFactory;
import org.apache.log4j.Logger;
import java.util.ArrayList;
@ -173,7 +173,7 @@ public class ComputerPlayerMCTS extends ComputerPlayer {
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(),
new XMageThreadFactory(ThreadUtils.THREAD_PREFIX_AI_SIMULATION_MCTS) // TODO: add player/game to thread name?
new XmageThreadFactory(ThreadUtils.THREAD_PREFIX_AI_SIMULATION_MCTS) // TODO: add player/game to thread name?
);
}