全局http 请求 header user-agent 配置为jpom

This commit is contained in:
bwcx_jzy 2021-07-31 17:10:20 +08:00
parent adc6462a8f
commit 96520b6367

View File

@ -10,6 +10,8 @@ import cn.hutool.core.lang.JarClassLoader;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ClassUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.GlobalHeaders;
import cn.hutool.http.Header;
import cn.hutool.system.SystemUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import cn.jiangzeyin.common.JsonMessage;
@ -66,10 +68,10 @@ public class JpomManifest {
*/
private String dataPath;
private static synchronized void init() {
if (JPOM_MANIFEST != null) {
return;
}
private static void init() {
if (JPOM_MANIFEST == null) {
synchronized (JpomManifest.class) {
if (JPOM_MANIFEST == null) {
JPOM_MANIFEST = new JpomManifest();
File jarFile = getRunPath();
if (jarFile.isFile()) {
@ -87,6 +89,10 @@ public class JpomManifest {
e.printStackTrace();
}
}
GlobalHeaders.INSTANCE.header(Header.USER_AGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36 Jpom " + JPOM_MANIFEST.getType(), true);
}
}
}
}
private JpomManifest() {