1 |
/* HttpURLConnection.java -- URLConnection class for HTTP protocol |
/* HttpURLConnection.java -- URLConnection class for HTTP protocol |
2 |
Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. |
Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004 |
3 |
|
Free Software Foundation, Inc. |
4 |
|
|
5 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
6 |
|
|
53 |
import java.net.Socket; |
import java.net.Socket; |
54 |
import java.net.URL; |
import java.net.URL; |
55 |
import java.net.URLConnection; |
import java.net.URLConnection; |
56 |
|
import java.security.AccessController; |
57 |
|
import java.security.PrivilegedAction; |
58 |
import java.util.HashMap; |
import java.util.HashMap; |
59 |
import java.util.Iterator; |
import java.util.Iterator; |
60 |
import java.util.Map; |
import java.util.Map; |
79 |
* The socket we are connected to |
* The socket we are connected to |
80 |
*/ |
*/ |
81 |
private Socket socket; |
private Socket socket; |
82 |
private static int proxyPort = 80; |
|
83 |
private static boolean proxyInUse = false; |
// Properties depeending on system properties settings |
84 |
private static String proxyHost = null; |
static int proxyPort = 80; |
85 |
|
static boolean proxyInUse = false; |
86 |
private static final String userAgent; |
static String proxyHost = null; |
87 |
|
static String userAgent; |
88 |
|
|
89 |
static |
static |
90 |
{ |
{ |
91 |
// Recognize some networking properties listed at |
// Make sure access control for system properties depends only on |
92 |
// http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. |
// our class ProtectionDomain, not on any (indirect) callers. |
93 |
String port = null; |
AccessController.doPrivileged(new PrivilegedAction() { |
94 |
proxyHost = System.getProperty("http.proxyHost"); |
public Object run() |
95 |
if (proxyHost != null) |
{ |
96 |
{ |
// Recognize some networking properties listed at |
97 |
proxyInUse = true; |
// http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. |
98 |
if ((port = System.getProperty("http.proxyPort")) != null) |
String port = null; |
99 |
{ |
proxyHost = System.getProperty("http.proxyHost"); |
100 |
try |
if (proxyHost != null) |
101 |
{ |
{ |
102 |
proxyPort = Integer.parseInt(port); |
proxyInUse = true; |
103 |
} |
if ((port = System.getProperty("http.proxyPort")) != null) |
104 |
catch (Throwable t) |
{ |
105 |
{ |
try |
106 |
// Nothing. |
{ |
107 |
} |
proxyPort = Integer.parseInt(port); |
108 |
} |
} |
109 |
} |
catch (Throwable t) |
110 |
|
{ |
111 |
userAgent = "gnu-classpath/" |
// Nothing. |
112 |
+ System.getProperty("gnu.classpath.version") |
} |
113 |
+ " (" |
} |
114 |
+ System.getProperty("gnu.classpath.vm.shortname") |
} |
115 |
+ "/" |
|
116 |
+ System.getProperty("java.vm.version") |
userAgent = System.getProperty("http.agent"); |
117 |
+ ")"; |
|
118 |
|
return null; |
119 |
|
} |
120 |
|
}); |
121 |
} |
} |
122 |
|
|
123 |
/** |
/** |