!1156 【轻量级pr】V6 httpUtil-createRequest从5.x迁移过来,方便使用

* HttpUtil类增加createRequest方法,方便使用(迁移从hutool5.x)
This commit is contained in:
dazer007
2024-01-17 03:01:12 +00:00
committed by Looly
parent d4d81e3dd2
commit 2959e1798d
2 changed files with 132 additions and 0 deletions

View File

@@ -54,6 +54,40 @@ public class HttpUtil {
return StrUtil.startWithIgnoreCase(url, "http:");
}
/**
* 创建Http请求对象
*
* @param method 方法枚举{@link Method}
* @param url 请求的URL可以使HTTP或者HTTPS
* @return {@link Request}
* @since 3.0.9
*/
public static Request createRequest(String url, Method method) {
return Request.of(url).method(method);
}
/**
* 创建Http GET请求对象
*
* @param url 请求的URL可以使HTTP或者HTTPS
* @return {@link Request}
* @since 3.2.0
*/
public static Request createGet(String url) {
return createRequest(url, Method.GET);
}
/**
* 创建Http POST请求对象
*
* @param url 请求的URL可以使HTTP或者HTTPS
* @return {@link Request}
* @since 3.2.0
*/
public static Request createPost(String url) {
return createRequest(url, Method.POST);
}
/**
* 发送get请求
*