Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e0bb8481
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看板
提交
e0bb8481
编写于
9月 05, 2008
作者:
W
wetmore
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
ba8c47f6
31070235
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
1 deletion
+51
-1
src/share/classes/java/net/HttpCookie.java
src/share/classes/java/net/HttpCookie.java
+33
-0
test/java/net/CookieHandler/TestHttpCookie.java
test/java/net/CookieHandler/TestHttpCookie.java
+18
-1
未找到文件。
src/share/classes/java/net/HttpCookie.java
浏览文件 @
e0bb8481
...
...
@@ -75,6 +75,7 @@ public final class HttpCookie implements Cloneable {
private
String
path
;
// Path=VALUE ... URLs that see the cookie
private
String
portlist
;
// Port[="portlist"] ... the port cookie may be returned to
private
boolean
secure
;
// Secure ... e.g. use SSL
private
boolean
httpOnly
;
// HttpOnly ... i.e. not accessible to scripts
private
int
version
=
1
;
// Version=1 ... RFC 2965 style
//
...
...
@@ -656,6 +657,32 @@ public final class HttpCookie implements Cloneable {
version
=
v
;
}
/**
* Returns {@code true} if this cookie contains the <i>HttpOnly</i>
* attribute. This means that the cookie should not be accessible to
* scripting engines, like javascript.
*
* @return {@code true} if this cookie should be considered http only.
* @see #setHttpOnly(boolean)
*/
public
boolean
isHttpOnly
()
{
return
httpOnly
;
}
/**
* Indicates whether the cookie should be considered HTTP Only. If set to
* {@code true} it means the cookie should not be accessible to scripting
* engines like javascript.
*
* @param httpOnly if {@code true} make the cookie HTTP only, i.e.
* only visible as part of an HTTP request.
* @see #isHttpOnly()
*/
public
void
setHttpOnly
(
boolean
httpOnly
)
{
this
.
httpOnly
=
httpOnly
;
}
/**
* The utility method to check whether a host name is in a domain
...
...
@@ -877,6 +904,7 @@ public final class HttpCookie implements Cloneable {
||
name
.
equalsIgnoreCase
(
"Port"
)
// rfc2965 only
||
name
.
equalsIgnoreCase
(
"Secure"
)
||
name
.
equalsIgnoreCase
(
"Version"
)
||
name
.
equalsIgnoreCase
(
"HttpOnly"
)
||
name
.
charAt
(
0
)
==
'$'
)
{
return
true
;
...
...
@@ -996,6 +1024,11 @@ public final class HttpCookie implements Cloneable {
cookie
.
setSecure
(
true
);
}
});
assignors
.
put
(
"httponly"
,
new
CookieAttributeAssignor
(){
public
void
assign
(
HttpCookie
cookie
,
String
attrName
,
String
attrValue
)
{
cookie
.
setHttpOnly
(
true
);
}
});
assignors
.
put
(
"version"
,
new
CookieAttributeAssignor
(){
public
void
assign
(
HttpCookie
cookie
,
String
attrName
,
String
attrValue
)
{
try
{
...
...
test/java/net/CookieHandler/TestHttpCookie.java
浏览文件 @
e0bb8481
...
...
@@ -24,7 +24,7 @@
/**
* @test
* @summary Unit test for java.net.HttpCookie
* @bug 6244040 6277796 6277801 6277808 6294071
* @bug 6244040 6277796 6277801 6277808 6294071
6692802
* @author Edward Wang
*/
...
...
@@ -178,6 +178,19 @@ public class TestHttpCookie {
}
TestHttpCookie
port
(
String
p
)
{
return
port
(
0
,
p
);
}
// check http only
TestHttpCookie
httpOnly
(
int
index
,
boolean
b
)
{
HttpCookie
cookie
=
cookies
.
get
(
index
);
if
(
cookie
==
null
||
b
!=
cookie
.
isHttpOnly
())
{
raiseError
(
"HttpOnly"
,
String
.
valueOf
(
cookie
.
isHttpOnly
()),
String
.
valueOf
(
b
));
}
return
this
;
}
TestHttpCookie
httpOnly
(
boolean
b
)
{
return
httpOnly
(
0
,
b
);
}
// check equality
static
void
eq
(
HttpCookie
ck1
,
HttpCookie
ck2
,
boolean
same
)
{
testCount
++;
...
...
@@ -362,6 +375,10 @@ public class TestHttpCookie {
}
catch
(
IllegalArgumentException
ignored
)
{
// expected exception; no-op
}
// CR 6692802: HttpOnly flag
test
(
"set-cookie: CUSTOMER=WILE_E_COYOTE;HttpOnly"
).
httpOnly
(
true
);
test
(
"set-cookie: CUSTOMER=WILE_E_COYOTE"
).
httpOnly
(
false
);
}
static
void
header
(
String
prompt
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录