test/sun/net/www/http/KeepAliveCache/B5045306.java
Print this page
*** 21,40 ****
* questions.
*/
/*
* @test
! * @bug 5045306 6356004
* @library ../../httptest/
* @build HttpCallback HttpServer HttpTransaction
* @run main/othervm B5045306
* @summary Http keep-alive implementation is not efficient
*/
import java.net.*;
import java.io.*;
- import java.nio.channels.*;
import java.lang.management.*;
/* Part 1:
* The http client makes a connection to a URL whos content contains a lot of
* data, more than can fit in the socket buffer. The client only reads
--- 21,39 ----
* questions.
*/
/*
* @test
! * @bug 5045306 6356004 6993490
* @library ../../httptest/
* @build HttpCallback HttpServer HttpTransaction
* @run main/othervm B5045306
* @summary Http keep-alive implementation is not efficient
*/
import java.net.*;
import java.io.*;
import java.lang.management.*;
/* Part 1:
* The http client makes a connection to a URL whos content contains a lot of
* data, more than can fit in the socket buffer. The client only reads
*** 162,171 ****
--- 161,178 ----
if (port1 != port2)
failed = true;
trans.setResponseHeader ("Content-length", Integer.toString(0));
+
+ /* Force the server to not respond for more that the timeout
+ * set by the keepalive cleaner (5000 millis). This ensures the
+ * timeout is correctly resets the default read timeout,
+ * infinity. See 6993490. */
+ System.out.println("server sleeping...");
+ try {Thread.sleep(6000); } catch (InterruptedException e) {}
+
trans.sendResponse(200, "OK");
} else if(path.equals("/part2")) {
System.out.println("Call to /part2");
byte[] responseBody = new byte[RESPONSE_DATA_LENGTH];
for (int i=0; i<responseBody.length; i++)