7005016: sqe test jhttp/HttpServer150013/HttpServer150013.java
Reviewed-by: chegar
This commit is contained in:
parent
8694378cd2
commit
04da999791
jdk
src/share/classes/sun/net/httpserver
test/com/sun/net/httpserver
@ -129,9 +129,22 @@ class Request {
|
||||
hdrs = new Headers();
|
||||
|
||||
char s[] = new char[10];
|
||||
int len = 0;
|
||||
|
||||
int firstc = is.read();
|
||||
|
||||
// check for empty headers
|
||||
if (firstc == CR || firstc == LF) {
|
||||
int c = is.read();
|
||||
if (c == CR || c == LF) {
|
||||
return hdrs;
|
||||
}
|
||||
s[0] = (char)firstc;
|
||||
len = 1;
|
||||
firstc = c;
|
||||
}
|
||||
|
||||
while (firstc != LF && firstc != CR && firstc >= 0) {
|
||||
int len = 0;
|
||||
int keyend = -1;
|
||||
int c;
|
||||
boolean inKey = firstc > ' ';
|
||||
@ -191,6 +204,7 @@ class Request {
|
||||
else
|
||||
v = String.copyValueOf(s, keyend, len - keyend);
|
||||
hdrs.add (k,v);
|
||||
len = 0;
|
||||
}
|
||||
return hdrs;
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ class SSLStreams {
|
||||
private void configureEngine(HttpsConfigurator cfg, InetSocketAddress addr){
|
||||
if (cfg != null) {
|
||||
Parameters params = new Parameters (cfg, addr);
|
||||
cfg.configure (params);
|
||||
//BEGIN_TIGER_EXCLUDE
|
||||
cfg.configure (params);
|
||||
SSLParameters sslParams = params.getSSLParameters();
|
||||
if (sslParams != null) {
|
||||
engine.setSSLParameters (sslParams);
|
||||
|
@ -42,7 +42,7 @@ class ServerConfig {
|
||||
static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec.
|
||||
|
||||
/* These values must be a reasonable multiple of clockTick */
|
||||
static final long DEFAULT_IDLE_INTERVAL = 300 ; // 5 min
|
||||
static final long DEFAULT_IDLE_INTERVAL = 30 ; // 5 min
|
||||
static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ;
|
||||
|
||||
static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever
|
||||
|
92
jdk/test/com/sun/net/httpserver/Test10.java
Normal file
92
jdk/test/com/sun/net/httpserver/Test10.java
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 7005016
|
||||
* @summary pit jdk7 b121 sqe test jhttp/HttpServer150013 failing
|
||||
* @run main/othervm -Dsun.net.httpserver.clockTick=1000 -Dsun.net.httpserver.idleInterval=3 Test10
|
||||
*/
|
||||
|
||||
import com.sun.net.httpserver.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/*
|
||||
* Test handling of empty Http headers
|
||||
*/
|
||||
|
||||
public class Test10 extends Test {
|
||||
public static void main (String[] args) throws Exception {
|
||||
System.out.print ("Test10: ");
|
||||
Handler handler = new Handler();
|
||||
InetSocketAddress addr = new InetSocketAddress (0);
|
||||
HttpServer server = HttpServer.create (addr, 0);
|
||||
int port = server.getAddress().getPort();
|
||||
HttpContext c2 = server.createContext ("/test", handler);
|
||||
|
||||
ExecutorService exec = Executors.newCachedThreadPool();
|
||||
server.setExecutor (exec);
|
||||
try {
|
||||
server.start ();
|
||||
doClient(port);
|
||||
System.out.println ("OK");
|
||||
} finally {
|
||||
delay();
|
||||
if (server != null)
|
||||
server.stop(2);
|
||||
if (exec != null)
|
||||
exec.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
static class Handler implements HttpHandler {
|
||||
volatile int invocation = 0;
|
||||
public void handle (HttpExchange t)
|
||||
throws IOException
|
||||
{
|
||||
InputStream is = t.getRequestBody();
|
||||
while (is.read() != -1);
|
||||
Headers map = t.getRequestHeaders();
|
||||
t.sendResponseHeaders (200, -1);
|
||||
t.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void doClient (int port) throws Exception {
|
||||
String s = "GET /test/1.html HTTP/1.1\r\n\r\n";
|
||||
|
||||
Socket socket = new Socket ("localhost", port);
|
||||
OutputStream os = socket.getOutputStream();
|
||||
os.write (s.getBytes());
|
||||
socket.setSoTimeout (10 * 1000);
|
||||
InputStream is = socket.getInputStream();
|
||||
int c;
|
||||
byte[] b = new byte [1024];
|
||||
while ((c=is.read(b)) != -1) ;
|
||||
is.close();
|
||||
socket.close();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user