@@ -133,14 +133,7 @@ private ResponseWrapper _doRequest(String url, String content,
133
133
try {
134
134
URL aUrl = new URL (url );
135
135
136
- if (null != _proxy ) {
137
- conn = (HttpURLConnection ) aUrl .openConnection (_proxy .getNetProxy ());
138
- if (_proxy .isAuthenticationNeeded ()) {
139
- conn .setRequestProperty ("Proxy-Authorization" , _proxy .getProxyAuthorization ());
140
- }
141
- } else {
142
- conn = (HttpURLConnection ) aUrl .openConnection ();
143
- }
136
+ conn = getConnectionByUrl (aUrl );
144
137
145
138
conn .setConnectTimeout (_connectionTimeout );
146
139
conn .setReadTimeout (_readTimeout );
@@ -315,7 +308,7 @@ private String formUpload(String urlStr, Map<String, String> textMap,
315
308
String BOUNDARY = "---------------------------" + System .currentTimeMillis ();
316
309
try {
317
310
URL url = new URL (urlStr );
318
- conn = ( HttpURLConnection ) url . openConnection ( );
311
+ conn = getConnectionByUrl ( url );
319
312
conn .setConnectTimeout (5000 );
320
313
conn .setReadTimeout (30000 );
321
314
conn .setDoOutput (true );
@@ -423,6 +416,19 @@ private String formUpload(String urlStr, Map<String, String> textMap,
423
416
return res ;
424
417
}
425
418
419
+ public HttpURLConnection getConnectionByUrl (URL url ) throws IOException {
420
+ HttpURLConnection conn ;
421
+ if (null != _proxy ) {
422
+ conn = (HttpURLConnection ) url .openConnection (_proxy .getNetProxy ());
423
+ if (_proxy .isAuthenticationNeeded ()) {
424
+ conn .setRequestProperty ("Proxy-Authorization" , _proxy .getProxyAuthorization ());
425
+ }
426
+ } else {
427
+ conn = (HttpURLConnection ) url .openConnection ();
428
+ }
429
+ return conn ;
430
+ }
431
+
426
432
private static class SimpleHostnameVerifier implements HostnameVerifier {
427
433
428
434
public boolean verify (String hostname , SSLSession session ) {
0 commit comments