Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
bb244939
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看板
提交
bb244939
编写于
10月 04, 2011
作者:
C
chegar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7095949: java/net/URLConnection/RedirectLimit.java and Redirect307Test fail intermittently
Reviewed-by: alanb
上级
b5955de7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
83 addition
and
85 deletion
+83
-85
test/java/net/URLConnection/Redirect307Test.java
test/java/net/URLConnection/Redirect307Test.java
+51
-63
test/java/net/URLConnection/RedirectLimit.java
test/java/net/URLConnection/RedirectLimit.java
+32
-22
未找到文件。
test/java/net/URLConnection/Redirect307Test.java
浏览文件 @
bb244939
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/**
/**
* @test
* @test
* @bug 4380568
* @bug 4380568
7095949
* @summary HttpURLConnection does not support 307 redirects
* @summary HttpURLConnection does not support 307 redirects
*/
*/
import
java.io.*
;
import
java.io.*
;
...
@@ -31,10 +31,9 @@ import java.net.*;
...
@@ -31,10 +31,9 @@ import java.net.*;
class
RedirServer
extends
Thread
{
class
RedirServer
extends
Thread
{
ServerSocket
s
;
static
final
int
TIMEOUT
=
10
*
1000
;
Socket
s1
;
InputStream
is
;
ServerSocket
ss
;
OutputStream
os
;
int
port
;
int
port
;
String
reply1Part1
=
"HTTP/1.1 307 Temporary Redirect\r\n"
+
String
reply1Part1
=
"HTTP/1.1 307 Temporary Redirect\r\n"
+
...
@@ -46,10 +45,10 @@ class RedirServer extends Thread {
...
@@ -46,10 +45,10 @@ class RedirServer extends Thread {
"Content-Type: text/html; charset=iso-8859-1\r\n\r\n"
+
"Content-Type: text/html; charset=iso-8859-1\r\n\r\n"
+
"<html>Hello</html>"
;
"<html>Hello</html>"
;
RedirServer
(
ServerSocket
y
)
{
RedirServer
(
ServerSocket
ss
)
throws
IOException
{
s
=
y
;
this
.
ss
=
ss
;
port
=
s
.
getLocalPort
(
);
this
.
ss
.
setSoTimeout
(
TIMEOUT
);
System
.
out
.
println
(
"Server created listening on "
+
port
);
port
=
this
.
ss
.
getLocalPort
(
);
}
}
String
reply2
=
"HTTP/1.1 200 Ok\r\n"
+
String
reply2
=
"HTTP/1.1 200 Ok\r\n"
+
...
@@ -59,74 +58,63 @@ class RedirServer extends Thread {
...
@@ -59,74 +58,63 @@ class RedirServer extends Thread {
"Content-Type: text/html; charset=iso-8859-1\r\n\r\n"
+
"Content-Type: text/html; charset=iso-8859-1\r\n\r\n"
+
"World"
;
"World"
;
static
final
byte
[]
requestEnd
=
new
byte
[]
{
'\r'
,
'\n'
,
'\r'
,
'\n'
};
// Read until the end of a HTTP request
void
readOneRequest
(
InputStream
is
)
throws
IOException
{
int
requestEndCount
=
0
,
r
;
while
((
r
=
is
.
read
())
!=
-
1
)
{
if
(
r
==
requestEnd
[
requestEndCount
])
{
requestEndCount
++;
if
(
requestEndCount
==
4
)
{
break
;
}
}
else
{
requestEndCount
=
0
;
}
}
}
public
void
run
()
{
public
void
run
()
{
try
{
try
{
s1
=
s
.
accept
();
try
(
Socket
s
=
ss
.
accept
())
{
is
=
s1
.
getInputStream
(
);
s
.
setSoTimeout
(
TIMEOUT
);
os
=
s1
.
getOutputStream
(
);
readOneRequest
(
s
.
getInputStream
()
);
is
.
read
()
;
String
reply
=
reply1Part1
+
port
+
reply1Part2
;
String
reply
=
reply1Part1
+
port
+
reply1Part2
;
s
.
getOutputStream
().
write
(
reply
.
getBytes
())
;
os
.
write
(
reply
.
getBytes
());
}
os
.
close
();
/* wait for redirected connection */
/* wait for redirected connection */
s
.
setSoTimeout
(
5000
);
try
(
Socket
s
=
ss
.
accept
())
{
s1
=
s
.
accept
();
s
.
setSoTimeout
(
TIMEOUT
);
is
=
s1
.
getInputStream
();
readOneRequest
(
s
.
getInputStream
());
os
=
s1
.
getOutputStream
();
s
.
getOutputStream
().
write
(
reply2
.
getBytes
());
is
.
read
();
}
os
.
write
(
reply2
.
getBytes
());
}
catch
(
Exception
e
)
{
os
.
close
();
}
catch
(
Exception
e
)
{
/* Just need thread to terminate */
System
.
out
.
println
(
"Server: caught "
+
e
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
finally
{
try
{
s
.
close
();
}
catch
(
IOException
unused
)
{}
try
{
s
s
.
close
();
}
catch
(
IOException
unused
)
{}
}
}
}
}
};
};
public
class
Redirect307Test
{
public
class
Redirect307Test
{
public
static
final
int
DELAY
=
10
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
int
port
;
ServerSocket
sock
=
new
ServerSocket
(
0
);
RedirServer
server
;
int
port
=
sock
.
getLocalPort
();
ServerSocket
sock
;
RedirServer
server
=
new
RedirServer
(
sock
);
server
.
start
();
try
{
sock
=
new
ServerSocket
(
0
);
URL
url
=
new
URL
(
"http://localhost:"
+
port
);
port
=
sock
.
getLocalPort
();
URLConnection
conURL
=
url
.
openConnection
();
}
conURL
.
setDoInput
(
true
);
catch
(
Exception
e
)
{
conURL
.
setAllowUserInteraction
(
false
);
System
.
out
.
println
(
"Exception: "
+
e
);
conURL
.
setUseCaches
(
false
);
return
;
}
try
(
InputStream
in
=
conURL
.
getInputStream
())
{
server
=
new
RedirServer
(
sock
);
server
.
start
();
try
{
String
s
=
"http://localhost:"
+
port
;
URL
url
=
new
URL
(
s
);
URLConnection
conURL
=
url
.
openConnection
();
conURL
.
setDoInput
(
true
);
conURL
.
setAllowUserInteraction
(
false
);
conURL
.
setUseCaches
(
false
);
InputStream
in
=
conURL
.
getInputStream
();
if
((
in
.
read
()
!=
(
int
)
'W'
)
||
(
in
.
read
()!=(
int
)
'o'
))
{
if
((
in
.
read
()
!=
(
int
)
'W'
)
||
(
in
.
read
()!=(
int
)
'o'
))
{
throw
new
RuntimeException
(
"Unexpected string read"
);
throw
new
RuntimeException
(
"Unexpected string read"
);
}
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Exception caught + "
+
e
);
}
}
}
}
}
test/java/net/URLConnection/RedirectLimit.java
浏览文件 @
bb244939
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
/**
/**
* @test
* @test
* @bug 4458085
* @bug 4458085
7095949
* @summary Redirects Limited to 5
* @summary Redirects Limited to 5
*/
*/
...
@@ -57,29 +57,43 @@ class RedirLimitServer extends Thread {
...
@@ -57,29 +57,43 @@ class RedirLimitServer extends Thread {
final
ServerSocket
ss
;
final
ServerSocket
ss
;
final
int
port
;
final
int
port
;
RedirLimitServer
(
ServerSocket
ss
)
{
RedirLimitServer
(
ServerSocket
ss
)
throws
IOException
{
this
.
ss
=
ss
;
this
.
ss
=
ss
;
port
=
ss
.
getLocalPort
();
port
=
this
.
ss
.
getLocalPort
();
this
.
ss
.
setSoTimeout
(
TIMEOUT
);
}
static
final
byte
[]
requestEnd
=
new
byte
[]
{
'\r'
,
'\n'
,
'\r'
,
'\n'
};
// Read until the end of a HTTP request
void
readOneRequest
(
InputStream
is
)
throws
IOException
{
int
requestEndCount
=
0
,
r
;
while
((
r
=
is
.
read
())
!=
-
1
)
{
if
(
r
==
requestEnd
[
requestEndCount
])
{
requestEndCount
++;
if
(
requestEndCount
==
4
)
{
break
;
}
}
else
{
requestEndCount
=
0
;
}
}
}
}
public
void
run
()
{
public
void
run
()
{
try
{
try
{
ss
.
setSoTimeout
(
TIMEOUT
);
for
(
int
i
=
0
;
i
<
NUM_REDIRECTS
;
i
++)
{
for
(
int
i
=
0
;
i
<
NUM_REDIRECTS
;
i
++)
{
try
(
Socket
s
=
ss
.
accept
())
{
try
(
Socket
s
=
ss
.
accept
())
{
s
.
setSoTimeout
(
TIMEOUT
);
s
.
setSoTimeout
(
TIMEOUT
);
InputStream
is
=
s
.
getInputStream
();
readOneRequest
(
s
.
getInputStream
());
OutputStream
os
=
s
.
getOutputStream
();
is
.
read
();
String
reply
=
reply1
+
port
+
"/redirect"
+
i
+
reply2
;
String
reply
=
reply1
+
port
+
"/redirect"
+
i
+
reply2
;
os
.
write
(
reply
.
getBytes
());
s
.
getOutputStream
()
.
write
(
reply
.
getBytes
());
}
}
}
}
try
(
Socket
s
=
ss
.
accept
())
{
try
(
Socket
s
=
ss
.
accept
())
{
InputStream
is
=
s
.
getInputStream
();
s
.
setSoTimeout
(
TIMEOUT
);
OutputStream
os
=
s
.
getOutputStream
();
readOneRequest
(
s
.
getInputStream
());
is
.
read
();
s
.
getOutputStream
().
write
(
reply3
.
getBytes
());
os
.
write
(
reply3
.
getBytes
());
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -96,21 +110,17 @@ public class RedirectLimit {
...
@@ -96,21 +110,17 @@ public class RedirectLimit {
RedirLimitServer
server
=
new
RedirLimitServer
(
ss
);
RedirLimitServer
server
=
new
RedirLimitServer
(
ss
);
server
.
start
();
server
.
start
();
InputStream
in
=
null
;
URL
url
=
new
URL
(
"http://localhost:"
+
port
);
try
{
URLConnection
conURL
=
url
.
openConnection
();
URL
url
=
new
URL
(
"http://localhost:"
+
port
);
URLConnection
conURL
=
url
.
openConnection
();
conURL
.
setDoInput
(
true
);
conURL
.
setDoInput
(
true
);
conURL
.
setAllowUserInteraction
(
false
);
conURL
.
setAllowUserInteraction
(
false
);
conURL
.
setUseCaches
(
false
);
conURL
.
setUseCaches
(
false
);
in
=
conURL
.
getInputStream
();
try
(
InputStream
in
=
conURL
.
getInputStream
())
{
if
((
in
.
read
()
!=
(
int
)
'W'
)
||
(
in
.
read
()!=(
int
)
'o'
))
{
if
((
in
.
read
()
!=
(
int
)
'W'
)
||
(
in
.
read
()!=(
int
)
'o'
))
{
throw
new
RuntimeException
(
"Unexpected string read"
);
throw
new
RuntimeException
(
"Unexpected string read"
);
}
}
}
finally
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录