75 |
* The socket we are connected to |
* The socket we are connected to |
76 |
*/ |
*/ |
77 |
private Socket socket; |
private Socket socket; |
|
|
|
|
private static String proxyHost = null; |
|
78 |
private static int proxyPort = 80; |
private static int proxyPort = 80; |
79 |
private static boolean proxyInUse = false; |
private static boolean proxyInUse = false; |
80 |
|
private static String proxyHost = null; |
81 |
|
|
82 |
static |
static |
83 |
{ |
{ |
84 |
// Recognize some networking properties listed at |
// Recognize some networking properties listed at |
85 |
// http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. |
// http://java.sun.com/j2se/1.4/docs/guide/net/properties.html. |
86 |
String port = null; |
String port = null; |
87 |
proxyHost = System.getProperty ("http.proxyHost"); |
proxyHost = System.getProperty("http.proxyHost"); |
|
|
|
88 |
if (proxyHost != null) |
if (proxyHost != null) |
89 |
{ |
{ |
90 |
proxyInUse = true; |
proxyInUse = true; |
91 |
|
if ((port = System.getProperty("http.proxyPort")) != null) |
|
if ((port = System.getProperty ("http.proxyPort")) != null) |
|
92 |
{ |
{ |
93 |
try |
try |
94 |
{ |
{ |
95 |
proxyPort = Integer.parseInt (port); |
proxyPort = Integer.parseInt(port); |
96 |
} |
} |
97 |
catch (Throwable t) |
catch (Throwable t) |
98 |
{ |
{ |
131 |
/** |
/** |
132 |
* Calls superclass constructor to initialize |
* Calls superclass constructor to initialize |
133 |
*/ |
*/ |
134 |
protected Connection (URL url) |
protected Connection(URL url) |
135 |
{ |
{ |
136 |
super (url); |
super(url); |
137 |
|
|
138 |
/* Set up some variables */ |
/* Set up some variables */ |
139 |
doOutput = false; |
doOutput = false; |
151 |
|
|
152 |
// Get address and port number. |
// Get address and port number. |
153 |
int port; |
int port; |
|
|
|
154 |
if (proxyInUse) |
if (proxyInUse) |
155 |
{ |
{ |
156 |
port = proxyPort; |
port = proxyPort; |
157 |
socket = new Socket (proxyHost, port); |
socket = new Socket(proxyHost, port); |
158 |
} |
} |
159 |
else |
else |
160 |
{ |
{ |
161 |
if ((port = url.getPort()) == -1) |
if ((port = url.getPort()) == -1) |
162 |
port = 80; |
port = 80; |
|
|
|
163 |
// Open socket and output stream. |
// Open socket and output stream. |
164 |
socket = new Socket (url.getHost(), port); |
socket = new Socket(url.getHost(), port); |
165 |
} |
} |
166 |
|
|
167 |
if (doInput) |
if (doInput) |
193 |
{ |
{ |
194 |
// Ignore errors in closing socket. |
// Ignore errors in closing socket. |
195 |
} |
} |
|
|
|
196 |
socket = null; |
socket = null; |
197 |
} |
} |
198 |
} |
} |
443 |
return bufferedOutputStream; |
return bufferedOutputStream; |
444 |
} |
} |
445 |
|
|
|
} // class Connection |
|
446 |
|
|
447 |
|
} |