对接 solon-net-httputils 实现流式转发
v2.7.3 后,httputils 添加异步接口支持。v3.1.1 后,异步基础上双添加流式获取支持。
1、使用 solon-net-httputils 流式转发文本内容
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-net-httputils</artifactId>
</dependency>
- 使用 httputils 流式获取并转发(不需要积累数据,省内存)
@Controller
public class DemoController {
@Mapping("/hello")
public Publisher<String> hello(String name) throws Exception{
return HttpUtils.http("https://solon.noear.org/")
.execAsTextStream("GET");
}
}