🎉 优化请求编码问题

This commit is contained in:
smallchill 2019-08-14 15:52:56 +08:00
parent f649d2b3ce
commit 061cdac58e
2 changed files with 7 additions and 1 deletions

View File

@ -32,6 +32,11 @@ public interface SecureConstant {
*/ */
String BASIC_HEADER_PREFIX = "Basic "; String BASIC_HEADER_PREFIX = "Basic ";
/**
* 认证请求头前缀
*/
String BASIC_HEADER_PREFIX_EXT = "Basic%20";
/** /**
* blade_client表字段 * blade_client表字段
*/ */

View File

@ -379,7 +379,8 @@ public class SecureUtil {
public static String[] extractAndDecodeHeader() { public static String[] extractAndDecodeHeader() {
// 获取请求头客户端信息 // 获取请求头客户端信息
String header = Objects.requireNonNull(WebUtil.getRequest()).getHeader(SecureConstant.BASIC_HEADER_KEY); String header = Objects.requireNonNull(WebUtil.getRequest()).getHeader(SecureConstant.BASIC_HEADER_KEY);
if (header == null || !header.startsWith(SecureConstant.BASIC_HEADER_PREFIX)) { header = Func.toStr(header).replace(SecureConstant.BASIC_HEADER_PREFIX_EXT, SecureConstant.BASIC_HEADER_PREFIX);
if (!header.startsWith(SecureConstant.BASIC_HEADER_PREFIX)) {
throw new SecureException("No client information in request header"); throw new SecureException("No client information in request header");
} }
byte[] base64Token = header.substring(6).getBytes(Charsets.UTF_8_NAME); byte[] base64Token = header.substring(6).getBytes(Charsets.UTF_8_NAME);