mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add test
This commit is contained in:
@@ -8,7 +8,10 @@ public class RFC3986Test {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void encodeQueryTest(){
|
public void encodeQueryTest(){
|
||||||
final String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=b", CharsetUtil.CHARSET_UTF_8);
|
String encode = RFC3986.QUERY_PARAM_VALUE.encode("a=b", CharsetUtil.CHARSET_UTF_8);
|
||||||
Assert.assertEquals("a=b", encode);
|
Assert.assertEquals("a=b", encode);
|
||||||
|
|
||||||
|
encode = RFC3986.QUERY_PARAM_VALUE.encode("a+1=b", CharsetUtil.CHARSET_UTF_8);
|
||||||
|
Assert.assertEquals("a+1=b", encode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1166,7 +1166,7 @@ public class HttpRequest extends HttpBase<HttpRequest> {
|
|||||||
* 对于非rest的GET请求,且处于重定向时,参数丢弃
|
* 对于非rest的GET请求,且处于重定向时,参数丢弃
|
||||||
*/
|
*/
|
||||||
private void urlWithParamIfGet() {
|
private void urlWithParamIfGet() {
|
||||||
if (Method.GET.equals(method) && false == this.isRest && this.redirectCount > 0) {
|
if (Method.GET.equals(method) && false == this.isRest && this.redirectCount <= 0) {
|
||||||
// 优先使用body形式的参数,不存在使用form
|
// 优先使用body形式的参数,不存在使用form
|
||||||
if (ArrayUtil.isNotEmpty(this.bodyBytes)) {
|
if (ArrayUtil.isNotEmpty(this.bodyBytes)) {
|
||||||
this.url.getQuery().parse(StrUtil.str(this.bodyBytes, this.charset), this.charset);
|
this.url.getQuery().parse(StrUtil.str(this.bodyBytes, this.charset), this.charset);
|
||||||
|
@@ -180,4 +180,14 @@ public class HttpRequestTest {
|
|||||||
GlobalInterceptor.INSTANCE.addInterceptor(Console::log);
|
GlobalInterceptor.INSTANCE.addInterceptor(Console::log);
|
||||||
HttpUtil.createGet("https://hutool.cn").execute();
|
HttpUtil.createGet("https://hutool.cn").execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Ignore
|
||||||
|
public void getWithFormTest(){
|
||||||
|
String url = "https://postman-echo.com/get";
|
||||||
|
final Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("aaa", "application+1@qqq.com");
|
||||||
|
HttpRequest request =HttpUtil.createGet(url).form(map);
|
||||||
|
Console.log(request.execute().body());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user