diff options
author | Joerg Brunsmann <joerg_brunsmann@yahoo.de> | 2003-01-03 18:05:00 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2003-01-03 18:05:00 +0000 |
commit | 9c91c80bb7595b799dc5c653de60f9c9d5898d14 (patch) | |
tree | 123ae9a1944193f9543ccfdf28377a32a95408a1 /libjava/gnu/gcj | |
parent | 0320cac3d8844f8ea44a8e3a27dd75f385b12061 (diff) | |
download | gcc-9c91c80bb7595b799dc5c653de60f9c9d5898d14.zip gcc-9c91c80bb7595b799dc5c653de60f9c9d5898d14.tar.gz gcc-9c91c80bb7595b799dc5c653de60f9c9d5898d14.tar.bz2 |
Connection.java (proxyPort, [...]): New static fields.
2003-01-03 Joerg Brunsmann <joerg_brunsmann@yahoo.de>
* gnu/gcj/protocol/http/Connection.java (proxyPort, proxyInUse,
proxyHost): New static fields.
(<clinit>): Initialize new fields.
(connect): Use proxy if necessary.
(usingProxy): Implement.
From-SVN: r60846
Diffstat (limited to 'libjava/gnu/gcj')
-rw-r--r-- | libjava/gnu/gcj/protocol/http/Connection.java | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/libjava/gnu/gcj/protocol/http/Connection.java b/libjava/gnu/gcj/protocol/http/Connection.java index caababa..1a6fc01 100644 --- a/libjava/gnu/gcj/protocol/http/Connection.java +++ b/libjava/gnu/gcj/protocol/http/Connection.java @@ -1,6 +1,6 @@ // Connection.java - Implementation of HttpURLConnection for http protocol. -/* Copyright (C) 1999, 2000 Free Software Foundation +/* Copyright (C) 1999, 2000, 2003 Free Software Foundation This file is part of libgcj. @@ -25,10 +25,11 @@ import java.util.Enumeration; /** * Written using on-line Java Platform 1.2 API Specification, as well * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). - * Status: Minimal subset of functionality. Proxies and Redirects - * not yet handled. FileNameMap handling needs to be considered. - * useCaches, ifModifiedSince, and allowUserInteraction need - * consideration as well as doInput and doOutput. + * Status: Minimal subset of functionality. Proxies only partially + * handled; Redirects not yet handled. FileNameMap handling needs to + * be considered. useCaches, ifModifiedSince, and + * allowUserInteraction need consideration as well as doInput and + * doOutput. */ class Connection extends HttpURLConnection @@ -40,6 +41,33 @@ class Connection extends HttpURLConnection private Vector hdrVec = new Vector(); private BufferedInputStream bufferedIn; + private static int proxyPort = 80; + private static boolean proxyInUse = false; + private static String proxyHost = null; + + static + { + // Recognize some networking properties listed at + // http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. + String port = null; + proxyHost = System.getProperty("http.proxyHost"); + if (proxyHost != null) + { + proxyInUse = true; + if ((port = System.getProperty("http.proxyPort")) != null) + { + try + { + proxyPort = Integer.parseInt(port); + } + catch (Throwable t) + { + // Nothing. + } + } + } + } + public Connection(URL url) { super(url); @@ -85,12 +113,20 @@ class Connection extends HttpURLConnection // Get address and port number. int port; - InetAddress destAddr = InetAddress.getByName(url.getHost()); - if ((port = url.getPort()) == -1) - port = 80; + if (proxyInUse) + { + port = proxyPort; + sock = new Socket(proxyHost, port); + } + else + { + InetAddress destAddr = InetAddress.getByName(url.getHost()); + if ((port = url.getPort()) == -1) + port = 80; + // Open socket and output stream. + sock = new Socket(destAddr, port); + } - // Open socket and output stream. - sock = new Socket(destAddr, port); PrintWriter out = new PrintWriter(sock.getOutputStream()); // Send request including any request properties that were set. @@ -123,10 +159,9 @@ class Connection extends HttpURLConnection } } - // TODO: public boolean usingProxy() public boolean usingProxy() { - return false; + return proxyInUse; } // Override default method in URLConnection. |