fix header

This commit is contained in:
Looly 2019-08-28 10:29:34 +08:00
parent 500be4aaba
commit 684bc1b6ae
3 changed files with 17 additions and 10 deletions

View File

@ -6,6 +6,8 @@
## 4.6.4 ## 4.6.4
### 新特性 ### 新特性
* 【http】 自动关闭HttpURLConnection的头安全检查issue#512@Github
* 【setting】 Setting变量替换支持从系统参数中取值
### Bug修复 ### Bug修复
* 【db】 解决ThreadLocalConnection多数据源被移除问题pr#66@Gitee * 【db】 解决ThreadLocalConnection多数据源被移除问题pr#66@Gitee

View File

@ -37,6 +37,10 @@ public enum GlobalHeaders {
* @return this * @return this
*/ */
public GlobalHeaders putDefault(boolean isReset) { public GlobalHeaders putDefault(boolean isReset) {
// 解决HttpURLConnection中无法自定义Host等头信息的问题
// https://stackoverflow.com/questions/9096987/how-to-overwrite-http-header-host-in-a-httpurlconnection/9098440
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
if (isReset) { if (isReset) {
this.headers.clear(); this.headers.clear();
} }

View File

@ -201,24 +201,25 @@ public class SettingLoader {
for (String var : vars) { for (String var : vars) {
key = ReUtil.get(reg_var, var, 1); key = ReUtil.get(reg_var, var, 1);
if (StrUtil.isNotBlank(key)) { if (StrUtil.isNotBlank(key)) {
// 查找变量名对应的值 // 本分组中查找变量名对应的值
String varValue = this.groupedMap.get(group, key); String varValue = this.groupedMap.get(group, key);
if (null != varValue) {
// 替换标识
value = value.replace(var, varValue);
} else {
// 跨分组查找 // 跨分组查找
if (null == varValue) {
final List<String> groupAndKey = StrUtil.split(key, CharUtil.DOT, 2); final List<String> groupAndKey = StrUtil.split(key, CharUtil.DOT, 2);
if (groupAndKey.size() > 1) { if (groupAndKey.size() > 1) {
varValue = this.groupedMap.get(groupAndKey.get(0), groupAndKey.get(1)); varValue = this.groupedMap.get(groupAndKey.get(0), groupAndKey.get(1));
}
}
// 系统参数中查找
if(null == varValue) {
varValue = System.getProperty(key);
}
if (null != varValue) { if (null != varValue) {
// 替换标识 // 替换标识
value = value.replace(var, varValue); value = value.replace(var, varValue);
} }
} }
} }
}
}
return value; return value;
} }
// ----------------------------------------------------------------------------------- Private method end // ----------------------------------------------------------------------------------- Private method end