URLConnection with FTP protocol
Ito Kazumitsu
kaffe@rufus.w3.org
Thu, 26 Apr 2001 11:27:33 +0900
It seems kaffe/net/www/protocol/ftp/FtpURLConnection.java
does nothing about URLConnection with FTP protocol.
I am not powerful enough to modify FtpURLConnection.java
so that it supports the real FTP. But it is not difficult
to use a proxy. Here are my patches to
kaffe/net/DefaultURLStreamHandlerFactory.java
and
kaffe/net/www/protocol/http/HttpURLConnection.java
which enable URLConnection with FTP protocol to work
if system properties ftp.proxyHost and ftp.proxyPort
are set.
--- DefaultURLStreamHandlerFactory.java.orig Sat Jul 24 09:56:14 1999
+++ DefaultURLStreamHandlerFactory.java Thu Apr 26 10:34:31 2001
@@ -26,6 +26,13 @@
public URLStreamHandler createURLStreamHandler(String protocol)
{
+ if (protocol.equals("ftp")) {
+ String proxyHost = System.getProperty("ftp.proxyHost");
+ if (proxyHost != null) {
+ protocol = "http";
+ }
+ }
+
URLStreamHandler handler;
handler = (URLStreamHandler)cache.get(protocol);
--- HttpURLConnection.java.orig Fri Jun 16 16:23:15 2000
+++ HttpURLConnection.java Thu Apr 26 10:45:34 2001
@@ -63,6 +63,17 @@
public HttpURLConnection(URL url) {
super(url);
+ if ((url.getProtocol()).equals("ftp")) {
+ proxyHost = System.getProperty("ftp.proxyHost");
+ if (proxyHost != null) {
+ useProxy = true;
+ String pp = System.getProperty("ftp.proxyPort");
+ if (pp != null) {
+ proxyPort = Integer.parseInt(pp);
+ }
+ }
+ // else I do not care.
+ }
}
public void connect() throws IOException {