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

View File

@ -37,6 +37,10 @@ public enum GlobalHeaders {
* @return this
*/
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) {
this.headers.clear();
}

View File

@ -201,22 +201,23 @@ public class SettingLoader {
for (String var : vars) {
key = ReUtil.get(reg_var, var, 1);
if (StrUtil.isNotBlank(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);
if (groupAndKey.size() > 1) {
varValue = this.groupedMap.get(groupAndKey.get(0), groupAndKey.get(1));
if (null != varValue) {
// 替换标识
value = value.replace(var, varValue);
}
}
}
// 系统参数中查找
if(null == varValue) {
varValue = System.getProperty(key);
}
if (null != varValue) {
// 替换标识
value = value.replace(var, varValue);
}
}
}
return value;