use of cn.hutool.http.HttpRequest in project hutool by looly.
the class HttpRequestTest method getWithParamsTest.
@Test
@Ignore
public void getWithParamsTest() {
String url = "http://gc.ditu.aliyun.com/geocoding?ccc=你好";
HttpRequest request = HttpRequest.get(url).setEncodeUrl(true).body("a=乌海");
String body = request.execute().body();
Console.log(body);
// String body2 = HttpUtil.get(url);
// Console.log(body2);
}
use of cn.hutool.http.HttpRequest in project hutool by looly.
the class HttpRequestTest method uploadTest.
@Test
@Ignore
public void uploadTest() {
File file = FileUtil.file("D:\\face.jpg");
// 方法一:自定义构建表单
HttpRequest request = //
HttpRequest.post(//
"http://localhost:8080/file/upload").form("file", //
file).form("fileType", "图片");
HttpResponse response = request.execute();
System.out.println(response.body());
}
use of cn.hutool.http.HttpRequest in project hutool by looly.
the class HttpRequestTest method customGetTest.
@Test
@Ignore
public void customGetTest() {
// 自定义构建HTTP GET请求,发送Http GET请求,针对HTTPS安全加密,可以自定义SSL
HttpRequest request = HttpRequest.get(url).charset(CharsetUtil.CHARSET_GBK).disableCache().setSSLProtocol(SSLSocketFactoryBuilder.TLSv12);
Console.log(request.execute().body());
}
use of cn.hutool.http.HttpRequest in project hutool by looly.
the class RestTest method postTest2.
@Test
@Ignore
public void postTest2() {
HttpRequest request = HttpRequest.post("http://211.162.39.204:8181/jeesite-simple/a/open/bizGwbnService/test").body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2"));
Console.log(request.execute().body());
}
use of cn.hutool.http.HttpRequest in project hutool by looly.
the class RestTest method postTest.
@Test
@Ignore
public void postTest() {
HttpRequest request = HttpRequest.post("http://localhost:8090/rest/restTest/").body(JSONUtil.createObj().put("aaa", "aaaValue").put("键2", "值2"));
Console.log(request.execute().body());
}
Aggregations