Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
42d4fd42
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
42d4fd42
编写于
1月 29, 2020
作者:
M
michaelm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8234825: Better Headings for HTTP Servers
Reviewed-by: chegar, dfuchs, igerasim
上级
f7597b4e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
2 deletion
+32
-2
src/share/classes/com/sun/net/httpserver/Headers.java
src/share/classes/com/sun/net/httpserver/Headers.java
+32
-2
未找到文件。
src/share/classes/com/sun/net/httpserver/Headers.java
浏览文件 @
42d4fd42
...
...
@@ -80,11 +80,14 @@ public class Headers implements Map<String,List<String>> {
char
[]
b
=
key
.
toCharArray
();
if
(
b
[
0
]
>=
'a'
&&
b
[
0
]
<=
'z'
)
{
b
[
0
]
=
(
char
)(
b
[
0
]
-
(
'a'
-
'A'
));
}
}
else
if
(
b
[
0
]
==
'\r'
||
b
[
0
]
==
'\n'
)
throw
new
IllegalArgumentException
(
"illegal character in key"
);
for
(
int
i
=
1
;
i
<
len
;
i
++)
{
if
(
b
[
i
]
>=
'A'
&&
b
[
i
]
<=
'Z'
)
{
b
[
i
]
=
(
char
)
(
b
[
i
]
+
(
'a'
-
'A'
));
}
}
else
if
(
b
[
i
]
==
'\r'
||
b
[
i
]
==
'\n'
)
throw
new
IllegalArgumentException
(
"illegal character in key"
);
}
return
new
String
(
b
);
}
...
...
@@ -126,6 +129,8 @@ public class Headers implements Map<String,List<String>> {
}
public
List
<
String
>
put
(
String
key
,
List
<
String
>
value
)
{
for
(
String
v
:
value
)
checkValue
(
v
);
return
map
.
put
(
normalize
(
key
),
value
);
}
...
...
@@ -137,6 +142,7 @@ public class Headers implements Map<String,List<String>> {
* @param value the header value to add to the header
*/
public
void
add
(
String
key
,
String
value
)
{
checkValue
(
value
);
String
k
=
normalize
(
key
);
List
<
String
>
l
=
map
.
get
(
k
);
if
(
l
==
null
)
{
...
...
@@ -146,6 +152,30 @@ public class Headers implements Map<String,List<String>> {
l
.
add
(
value
);
}
private
static
void
checkValue
(
String
value
)
{
int
len
=
value
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
value
.
charAt
(
i
);
if
(
c
==
'\r'
)
{
// is allowed if it is followed by \n and a whitespace char
if
(
i
>=
len
-
2
)
{
throw
new
IllegalArgumentException
(
"Illegal CR found in header"
);
}
char
c1
=
value
.
charAt
(
i
+
1
);
char
c2
=
value
.
charAt
(
i
+
2
);
if
(
c1
!=
'\n'
)
{
throw
new
IllegalArgumentException
(
"Illegal char found after CR in header"
);
}
if
(
c2
!=
' '
&&
c2
!=
'\t'
)
{
throw
new
IllegalArgumentException
(
"No whitespace found after CRLF in header"
);
}
i
+=
2
;
}
else
if
(
c
==
'\n'
)
{
throw
new
IllegalArgumentException
(
"Illegal LF found in header"
);
}
}
}
/**
* sets the given value as the sole header value
* for the given key. If the mapping does not
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录