mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix(hutool-http): user-agent 增加企业微信和钉钉. 去除 Browser 中的行尾注释
This commit is contained in:
@@ -4,19 +4,30 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ReUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import cn.hutool.http.Header;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import lombok.SneakyThrows;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HttpUtilTest {
|
||||
@Test
|
||||
public void utlTest() {
|
||||
File file = new File("/Users/Downloads/test");
|
||||
File zipFile = new File(file, "demo.zip");
|
||||
HttpUtil.downloadFile("http://192.168.6.106:8000/demo.zip", file);
|
||||
ZipUtil.unzip(zipFile);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
|
@@ -204,4 +204,30 @@ public class UserAgentUtilTest {
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWorkWxTest() {
|
||||
String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 wxwork/3.0.31 MicroMessenger/7.0.1 Language/zh";
|
||||
UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("wxwork", ua.getBrowser().toString());
|
||||
Assert.assertEquals("3.0.31", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("605.1.15", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseDingTalkTest() {
|
||||
String uaString = "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/18A373 AliApp(DingTalk/5.1.33) com.laiwang.DingTalk/13976299 Channel/201200 language/zh-Hans-CN WK";
|
||||
UserAgent ua = UserAgentUtil.parse(uaString);
|
||||
Assert.assertEquals("DingTalk", ua.getBrowser().toString());
|
||||
Assert.assertEquals("5.1.33", ua.getVersion());
|
||||
Assert.assertEquals("Webkit", ua.getEngine().toString());
|
||||
Assert.assertEquals("605.1.15", ua.getEngineVersion());
|
||||
Assert.assertEquals("iPhone", ua.getOs().toString());
|
||||
Assert.assertEquals("iPhone", ua.getPlatform().toString());
|
||||
Assert.assertTrue(ua.isMobile());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user