mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
HttpRequest 新增 thenFunction 方法
This commit is contained in:
parent
72b9741928
commit
59672d0812
@ -35,6 +35,7 @@ import java.nio.charset.Charset;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* http请求类<br>
|
||||
@ -1025,6 +1026,18 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行Request请求后,对响应内容后续处理<br>
|
||||
* 处理结束后关闭连接
|
||||
*
|
||||
* @param function 响应内容处理函数
|
||||
*/
|
||||
public <T> T thenFunction(Function<HttpResponse, T> function) {
|
||||
try (HttpResponse response = execute(true)) {
|
||||
return function.apply(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单验证,生成的头信息类似于:
|
||||
* <pre>
|
||||
|
Loading…
x
Reference in New Issue
Block a user