mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add method
This commit is contained in:
parent
c4dd255a1d
commit
b8e8552186
@ -19,9 +19,11 @@ import org.dromara.hutool.core.convert.Convert;
|
|||||||
import org.dromara.hutool.core.map.MapUtil;
|
import org.dromara.hutool.core.map.MapUtil;
|
||||||
import org.dromara.hutool.core.text.StrUtil;
|
import org.dromara.hutool.core.text.StrUtil;
|
||||||
import org.dromara.hutool.http.HttpUtil;
|
import org.dromara.hutool.http.HttpUtil;
|
||||||
|
import org.dromara.hutool.http.auth.HttpAuthUtil;
|
||||||
import org.dromara.hutool.http.meta.HeaderName;
|
import org.dromara.hutool.http.meta.HeaderName;
|
||||||
|
|
||||||
import java.net.HttpCookie;
|
import java.net.HttpCookie;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -216,6 +218,21 @@ public interface HeaderOperation<T extends HeaderOperation<T>> {
|
|||||||
|
|
||||||
// region ----------------------------------------------------------- auth
|
// region ----------------------------------------------------------- auth
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单验证,生成的头信息类似于:
|
||||||
|
* <pre>
|
||||||
|
* Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @param password 密码
|
||||||
|
* @param charset 编码
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
default T basicAuth(final String username, final String password, final Charset charset) {
|
||||||
|
return auth(HttpAuthUtil.buildBasicAuth(username, password, charset));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌验证,生成的头类似于:"Authorization: Bearer XXXXX",一般用于JWT
|
* 令牌验证,生成的头类似于:"Authorization: Bearer XXXXX",一般用于JWT
|
||||||
*
|
*
|
||||||
|
@ -237,6 +237,8 @@ public class Request implements HeaderOperation<Request> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// region header
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends Collection<String>> headers() {
|
public Map<String, ? extends Collection<String>> headers() {
|
||||||
return MapUtil.view(this.headers);
|
return MapUtil.view(this.headers);
|
||||||
@ -270,6 +272,22 @@ public class Request implements HeaderOperation<Request> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 简单验证,生成的头信息类似于:
|
||||||
|
* <pre>
|
||||||
|
* Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @param password 密码
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
public Request basicAuth(final String username, final String password) {
|
||||||
|
return basicAuth(username, password, charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
// region body get
|
// region body get
|
||||||
/**
|
/**
|
||||||
* 获取请求体
|
* 获取请求体
|
||||||
|
Loading…
x
Reference in New Issue
Block a user