This commit is contained in:
Looly
2024-01-18 16:27:19 +08:00
parent 50367a4a9f
commit c84db9070a
4 changed files with 65 additions and 42 deletions

View File

@@ -0,0 +1,26 @@
package org.dromara.hutool.http.client;
import org.dromara.hutool.http.HttpGlobalConfig;
import org.dromara.hutool.http.HttpUtil;
import org.dromara.hutool.http.client.engine.okhttp.OkHttpEngine;
import org.dromara.hutool.http.meta.HeaderName;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
public class IssueI8WU4MTest {
@Test
@Disabled
void timeoutTest() {
//设置超时单位毫秒这里1毫秒按道理100%超时
HttpGlobalConfig.setTimeout(1);
final String body = HttpUtil.createGet("https://restapi.amap.com/v3/ip?Key=ad054b1810672fb0ff6107cd71518837")
.header(HeaderName.CONTENT_TYPE, "application/x-www-form-urlencoded; charset=utf-8")
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0")
.send(new OkHttpEngine())
.body().
getString();
System.out.println(body);
}
}