mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test
This commit is contained in:
parent
b2cac34f9a
commit
201fe2404f
30
hutool-http/src/test/java/cn/hutool/http/Issue2901Test.java
Normal file
30
hutool-http/src/test/java/cn/hutool/http/Issue2901Test.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package cn.hutool.http;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
|
import cn.hutool.core.io.resource.FileResource;
|
||||||
|
import cn.hutool.core.io.resource.HttpResource;
|
||||||
|
import cn.hutool.core.lang.Console;
|
||||||
|
import cn.hutool.http.client.Request;
|
||||||
|
import cn.hutool.http.client.Response;
|
||||||
|
import cn.hutool.http.client.body.ResourceBody;
|
||||||
|
import cn.hutool.http.meta.ContentType;
|
||||||
|
import cn.hutool.http.meta.Method;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class Issue2901Test {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void bodyTest() {
|
||||||
|
// 自定义请求体,请求体作为资源读取,解决一次性读取到内存的问题
|
||||||
|
final Response res = Request.of("http://localhost:8888/restTest")
|
||||||
|
.method(Method.POST)
|
||||||
|
.body(new ResourceBody(
|
||||||
|
new HttpResource(new FileResource("d:/test/test.jpg"), ContentType.OCTET_STREAM.getValue())))
|
||||||
|
.send();
|
||||||
|
|
||||||
|
Console.log(res.bodyStr());
|
||||||
|
IoUtil.close(res);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user