3261N/A * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 2981N/A * @bug 5045306 6356004 6993490 0N/A * @library ../../httptest/ 0N/A * @build HttpCallback HttpServer HttpTransaction 0N/A * @summary Http keep-alive implementation is not efficient 0N/A * The http client makes a connection to a URL whos content contains a lot of 0N/A * data, more than can fit in the socket buffer. The client only reads 0N/A * 1 byte of the data from the InputStream leaving behind more data than can 0N/A * fit in the socket buffer. The client then makes a second call to the http 0N/A * server. If the connection port used by the client is the same as for the 0N/A * first call then that means that the connection is being reused. 0N/A * Test buggy webserver that sends less data than it specifies in its 0N/A * Content-length header. 0N/A //Only read 1 byte of response data and close the stream 0N/A // Allow the KeepAliveStreamCleaner thread to read the data left behind and cache the connection. 0N/A // Allow the KeepAliveStreamCleaner thread to try and read the data left behind and cache the connection. 0N/A break;
// thread has died, OK 0N/A // if Keep-Alive-SocketCleaner consumes more than 50% of cpu then we 0N/A // can assume a recursive loop. 0N/A if (
total >=
1000000000)
// 1 second, or 1 billion nanoseconds 0N/A // Need to have enough data here that is too large for the socket buffer to hold. 0N/A // Also http.KeepAlive.remainingData must be greater than this value, default is 256K. 2981N/A /* Force the server to not respond for more that the timeout 2981N/A * set by the keepalive cleaner (5000 millis). This ensures the 2981N/A * timeout is correctly resets the default read timeout, 2981N/A * infinity. See 6993490. */ 0N/A // override the Content-length header to be greater than the actual response body 0N/A // now close the socket