/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 6498566
* @summary URL.openConnection(Proxy.NO_PROXY) may connect through a proxy.
*/
/* Creates a simple proxy and http server that just return 200 OK.
* Open a URL pointing to the http server and specify that the
* connection should use the proxy. Now make a second connection
* to the same URL, specifying that no proxy is to be used.
* We count the amount of requests being sent to each server. There
* should be only one request sent to each.
*/
public class ProxyFromCache
{
try {
} catch (Exception e) {
return;
}
proxyServer.start();
httpServer.start();
try {
// 1st connection.
byte[] ba = new byte[1024];
// 2nd connection.
try {
httpSSocket.close();
} catch (IOException e) {}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
{
private int connectionCount;
"Content-Length: 0\r\n\r\n";
}
public void run() {
try {
// If we get here then we received a second request.
} catch (Exception e) {
//e.printStackTrace();
} catch (IOException ioe) {}
}
}
}
public int getConnectionCount() {
return connectionCount;
}
public void terminate() {
} catch (IOException ioe) {}
}
}
}