/*
* 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 4720715
* @summary FTP with user and password doesn't work through proxy
*/
/*
* The goal here is to simulate a simplified (a lot) HTTP proxy server to see
* what kind of URL is passed down the line by the URLConnection.
* In particular, we want to make sure no information is lost (like username
* and password).
*/
public class ProxyTest {
/*
* Proxy server as an innerclass. Has to run in a separate thread
*/
private int port;
private volatile boolean done = false;
/**
* This Inner class will handle ONE client at a time.
* That's where 99% of the protocol handling is done.
*/
}
public void run() {
boolean done = false;
try {
return;
}
/*
* Look for the actual GET request and extract the URL
* A regex should do the trick.
*/
while (!done) {
try {
if (m.find())
done = true;
} catch (IOException ioe) {
try {
}
done = true;
}
}
/*
* sends back a 'dummy' document for completness sake.
*/
}
}
}
public int getPort() {
return server.getLocalPort();
return 0;
}
return askedUrl;
}
/**
* A way to tell the server that it can stop.
*/
synchronized public void terminate() {
done = true;
}
public void run() {
try {
while (!done) {
}
} catch (Exception e) {
} finally {
}
}
}
}
try {
do {
} catch (Exception e) {
e.printStackTrace();
} finally {
}
/*
* If the URLs don't match, we've got a bug!
*/
}
}
}