This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Networking properties


Hi,

the attached patch uses two proxy properties listed at

  http://java.sun.com/j2se/1.4/docs/guide/net/properties.html

in gnu.gcj.protocol.http.Connection. Can someone please 
review the patch and check it in. Thanks.

Jörg

*** Connection.java.orig	Fri Dec 20 14:45:16 2002
--- Connection.java	Fri Dec 20 15:26:03 2002
*************** class Connection extends HttpURLConnecti
*** 40,45 ****
--- 40,67 ----
    private Vector hdrVec = new Vector();
    private BufferedInputStream bufferedIn;
  
+   private static int proxyPort = 80;
+   private static boolean usingProxy = 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) {
+       usingProxy = true;
+       if ((port = System.getProperty("http.proxyPort")) != null) {
+         try {
+           proxyPort = Integer.parseInt(port);
+         } catch (Throwable t) {
+           // nothing  
+         }
+       }
+     }
+   }
+ 
    public Connection(URL url)
    {
      super(url);
*************** class Connection extends HttpURLConnecti
*** 85,96 ****
  
      // Get address and port number.
      int port;
-     InetAddress destAddr = InetAddress.getByName(url.getHost());
-     if ((port = url.getPort()) == -1)
-       port = 80;
  
!     // 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.
--- 107,123 ----
  
      // Get address and port number.
      int port;
  
!     if (usingProxy) {
!       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);
!     }
      PrintWriter out = new PrintWriter(sock.getOutputStream());
  
      // Send request including any request properties that were set.
*************** class Connection extends HttpURLConnecti
*** 123,132 ****
        }
    }
  
-   // TODO: public boolean usingProxy()
    public boolean usingProxy()
    {
!     return false;
    }
  
    // Override default method in URLConnection.
--- 150,158 ----
        }
    }
  
    public boolean usingProxy()
    {
!     return usingProxy;
    }
  
    // Override default method in URLConnection.



__________________________________________________________________

Gesendet von Yahoo! Mail - http://mail.yahoo.de
Weihnachts-Einkäufe ohne Stress! http://shopping.yahoo.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]