mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix comment
This commit is contained in:
parent
b048cc7fd7
commit
6dc8524e69
@ -3608,7 +3608,7 @@ public class CharSequenceUtil {
|
||||
* replaceFun可以通过{@link Matcher}提取出匹配到的内容的不同部分,然后经过重新处理、组装变成新的内容放回原位。
|
||||
*
|
||||
* <pre class="code">
|
||||
* replaceAll(this.content, "(\\d+)", parameters -> "-" + parameters.group(1) + "-")
|
||||
* replace(this.content, "(\\d+)", parameters -> "-" + parameters.group(1) + "-")
|
||||
* // 结果为:"ZZZaaabbbccc中文-1234-"
|
||||
* </pre>
|
||||
*
|
||||
|
@ -32,6 +32,7 @@ import java.net.URLStreamHandler;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* http请求类<br>
|
||||
@ -968,6 +969,19 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
return httpResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行Request请求后,对响应内容后续处理<br>
|
||||
* 处理结束后关闭连接
|
||||
*
|
||||
* @param consumer 响应内容处理函数
|
||||
* @since 5.7.8
|
||||
*/
|
||||
public void then(Consumer<HttpResponse> consumer) {
|
||||
try (HttpResponse response = execute(true)) {
|
||||
consumer.accept(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 简单验证,生成的头信息类似于:
|
||||
* <pre>
|
||||
@ -1228,6 +1242,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
||||
* 1. 存在资源对象(fileForm非空)
|
||||
* 2. 用户自定义头为multipart/form-data开头
|
||||
* </pre>
|
||||
*
|
||||
* @return 是否为multipart/form-data表单
|
||||
* @since 5.3.5
|
||||
*/
|
||||
|
@ -5,7 +5,6 @@ import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.ssl.SSLSocketFactoryBuilder;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -29,6 +28,14 @@ public class HttpRequestTest {
|
||||
Console.log(body);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void getHttpsThenTest() {
|
||||
HttpRequest
|
||||
.get("https://hutool.cn")
|
||||
.then(response -> Console.log(response.body()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void getCookiesTest() {
|
||||
@ -126,9 +133,10 @@ public class HttpRequestTest {
|
||||
map.put("size", "2");
|
||||
map.put("sizes", list);
|
||||
|
||||
String s = JSONUtil.toJsonStr(map);
|
||||
HttpRequest request = HttpUtil.createGet("http://localhost:8888/get");
|
||||
Console.log(request.execute().body());
|
||||
HttpRequest
|
||||
.get("http://localhost:8888/get")
|
||||
.form(map)
|
||||
.then(resp -> Console.log(resp.body()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user