提交 078c4975 编写于 作者: X xuelei

6941936: Broken pipe error of test case DNSIdentities.java

Reviewed-by: chegar
上级 0bf32aa9
......@@ -623,6 +623,11 @@ public class DNSIdentities {
*/
volatile static boolean serverReady = false;
/*
* Is the connection ready to close?
*/
volatile static boolean closeReady = false;
/*
* Turn on SSL debugging?
*/
......@@ -671,7 +676,10 @@ public class DNSIdentities {
out.flush();
} finally {
// close the socket
Thread.sleep(2000);
while (!closeReady) {
Thread.sleep(50);
}
System.out.println("Server closing socket");
sslSocket.close();
serverReady = false;
......@@ -704,13 +712,18 @@ public class DNSIdentities {
URL url = new URL("https://localhost:" + serverPort+"/");
System.out.println("url is "+url.toString());
try {
http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode);
} finally {
if (http != null) {
http.disconnect();
}
closeReady = true;
}
}
/*
* =============================================================
......
......@@ -60,6 +60,11 @@ public class HttpsPost {
*/
volatile static boolean serverReady = false;
/*
* Is the connection ready to close?
*/
volatile static boolean closeReady = false;
/*
* Turn on SSL debugging?
*/
......@@ -98,10 +103,13 @@ public class HttpsPost {
serverReady = true;
SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
try {
InputStream sslIS = sslSocket.getInputStream();
OutputStream sslOS = sslSocket.getOutputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(sslIS));
BufferedReader br =
new BufferedReader(new InputStreamReader(sslIS));
PrintStream ps = new PrintStream(sslOS);
// process HTTP POST request from client
System.out.println("status line: "+br.readLine());
String msg = null;
......@@ -114,10 +122,16 @@ public class HttpsPost {
ps.println("HTTP/1.1 500 Not OK\n\n");
}
ps.flush();
Thread.sleep(2000);
// close the socket
while (!closeReady) {
Thread.sleep(50);
}
} finally {
sslSocket.close();
sslServerSocket.close();
}
}
/*
* Define the client side of the test.
......@@ -144,12 +158,17 @@ public class HttpsPost {
http.setRequestMethod("POST");
PrintStream ps = new PrintStream(http.getOutputStream());
try {
ps.println(postMsg);
ps.flush();
if (http.getResponseCode() != 200) {
throw new RuntimeException("test Failed");
}
} finally {
ps.close();
http.disconnect();
closeReady = true;
}
}
static class NameVerifier implements HostnameVerifier {
......
......@@ -623,6 +623,11 @@ public class IPAddressDNSIdentities {
*/
volatile static boolean serverReady = false;
/*
* Is the connection ready to close?
*/
volatile static boolean closeReady = false;
/*
* Turn on SSL debugging?
*/
......@@ -671,7 +676,10 @@ public class IPAddressDNSIdentities {
out.flush();
} finally {
// close the socket
Thread.sleep(2000);
while (!closeReady) {
Thread.sleep(50);
}
System.out.println("Server closing socket");
sslSocket.close();
serverReady = false;
......@@ -716,8 +724,11 @@ public class IPAddressDNSIdentities {
// no subject alternative names matching IP address 127.0.0.1 found
// that's the expected exception, ignore it.
} finally {
if (http != null) {
http.disconnect();
}
closeReady = true;
}
}
/*
......
......@@ -624,6 +624,11 @@ public class IPAddressIPIdentities {
*/
volatile static boolean serverReady = false;
/*
* Is the connection ready to close?
*/
volatile static boolean closeReady = false;
/*
* Turn on SSL debugging?
*/
......@@ -672,7 +677,10 @@ public class IPAddressIPIdentities {
out.flush();
} finally {
// close the socket
Thread.sleep(2000);
while (!closeReady) {
Thread.sleep(50);
}
System.out.println("Server closing socket");
sslSocket.close();
serverReady = false;
......@@ -705,13 +713,18 @@ public class IPAddressIPIdentities {
URL url = new URL("https://127.0.0.1:" + serverPort+"/");
System.out.println("url is "+url.toString());
try {
http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode);
} finally {
if (http != null) {
http.disconnect();
}
closeReady = true;
}
}
/*
* =============================================================
......
......@@ -624,6 +624,11 @@ public class IPIdentities {
*/
volatile static boolean serverReady = false;
/*
* Is the connection ready to close?
*/
volatile static boolean closeReady = false;
/*
* Turn on SSL debugging?
*/
......@@ -672,7 +677,10 @@ public class IPIdentities {
out.flush();
} finally {
// close the socket
Thread.sleep(2000);
while (!closeReady) {
Thread.sleep(50);
}
System.out.println("Server closing socket");
sslSocket.close();
serverReady = false;
......@@ -705,13 +713,18 @@ public class IPIdentities {
URL url = new URL("https://localhost:" + serverPort+"/");
System.out.println("url is "+url.toString());
try {
http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode);
} finally {
if (http != null) {
http.disconnect();
}
closeReady = true;
}
}
/*
* =============================================================
......
......@@ -623,6 +623,11 @@ public class Identities {
*/
volatile static boolean serverReady = false;
/*
* Is the connection ready to close?
*/
volatile static boolean closeReady = false;
/*
* Turn on SSL debugging?
*/
......@@ -671,7 +676,10 @@ public class Identities {
out.flush();
} finally {
// close the socket
Thread.sleep(2000);
while (!closeReady) {
Thread.sleep(50);
}
System.out.println("Server closing socket");
sslSocket.close();
serverReady = false;
......@@ -704,13 +712,18 @@ public class Identities {
URL url = new URL("https://localhost:" + serverPort+"/");
System.out.println("url is "+url.toString());
try {
http = (HttpsURLConnection)url.openConnection();
int respCode = http.getResponseCode();
System.out.println("respCode = "+respCode);
} finally {
if (http != null) {
http.disconnect();
}
closeReady = true;
}
}
/*
* =============================================================
......
......@@ -60,6 +60,11 @@ public class Redirect {
*/
volatile static boolean serverReady = false;
/*
* Is the connection ready to close?
*/
volatile static boolean closeReady = false;
/*
* Turn on SSL debugging?
*/
......@@ -98,25 +103,34 @@ public class Redirect {
serverReady = true;
SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
try {
InputStream sslIS = sslSocket.getInputStream();
OutputStream sslOS = sslSocket.getOutputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(sslIS));
BufferedReader br =
new BufferedReader(new InputStreamReader(sslIS));
PrintStream ps = new PrintStream(sslOS);
// process HTTP POST request from client
System.out.println("status line: "+br.readLine());
ps.println("HTTP/1.1 307 Redirect");
ps.println("Location: https://localhost:"+serverPort+"/index.html\n\n");
ps.println("Location: https://localhost:" + serverPort +
"/index.html\n\n");
ps.flush();
sslSocket = (SSLSocket) sslServerSocket.accept();
sslOS = sslSocket.getOutputStream();
ps = new PrintStream(sslOS);
ps.println("HTTP/1.1 200 Redirect succeeded\n\n");
ps.flush();
Thread.sleep(2000);
} finally {
// close the socket
while (!closeReady) {
Thread.sleep(50);
}
sslSocket.close();
sslServerSocket.close();
}
}
/*
* Define the client side of the test.
......@@ -139,11 +153,15 @@ public class Redirect {
HttpsURLConnection.setDefaultHostnameVerifier(
new NameVerifier());
HttpsURLConnection http = (HttpsURLConnection)url.openConnection();
try {
System.out.println("response header: "+http.getHeaderField(0));
if (http.getResponseCode() != 200) {
throw new RuntimeException("test Failed");
}
} finally {
http.disconnect();
closeReady = true;
}
}
static class NameVerifier implements HostnameVerifier {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册