mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
!1156 【轻量级pr】V6 httpUtil-createRequest从5.x迁移过来,方便使用
* HttpUtil类增加createRequest方法,方便使用(迁移从hutool5.x)
This commit is contained in:
@@ -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请求
|
||||
*
|
||||
|
Reference in New Issue
Block a user