Changeset 852 for java/ModDepotAccess/src/net
- Timestamp:
- May 3, 2013, 2:25:21 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/ModDepotAccess/src/net/oni2/moddepot/DepotManager.java
r748 r852 7 7 import java.io.IOException; 8 8 import java.io.InputStreamReader; 9 import java. io.UnsupportedEncodingException;10 import java.net.U nknownHostException;9 import java.net.HttpURLConnection; 10 import java.net.URL; 11 11 import java.util.Date; 12 12 import java.util.Enumeration; … … 16 16 import java.util.zip.ZipFile; 17 17 18 import net.oni2.ProxySettings; 19 import net.oni2.httpfiledownloader.FileDownloader; 18 20 import net.oni2.moddepot.model.File; 19 21 import net.oni2.moddepot.model.Node; … … 23 25 import net.oni2.moddepot.model.TaxonomyTerm; 24 26 import net.oni2.moddepot.model.TaxonomyVocabulary; 25 import net.oni2.httpfiledownloader.FileDownloader; 26 27 import org.apache.http.HttpResponse; 28 import org.apache.http.client.methods.HttpHead; 29 import org.apache.http.client.methods.HttpRequestBase; 30 import org.apache.http.impl.client.DefaultHttpClient; 27 31 28 import org.json.JSONArray; 32 29 import org.json.JSONException; … … 214 211 */ 215 212 public boolean checkConnection() { 216 HttpRequestBase httpQuery = null;217 218 213 try { 219 DefaultHttpClient httpclient = new DefaultHttpClient(); 220 httpQuery = new HttpHead(DepotConfig.depotUrl); 221 HttpResponse response = httpclient.execute(httpQuery); 222 int code = response.getStatusLine().getStatusCode(); 214 HttpURLConnection con = (HttpURLConnection) new URL( 215 DepotConfig.depotUrl).openConnection(ProxySettings 216 .getInstance().getProxy()); 217 con.setRequestMethod("HEAD"); 218 int code = con.getResponseCode(); 223 219 return (code >= 200) && (code <= 299); 224 } catch (UnknownHostException e) {225 } catch (UnsupportedEncodingException e) {226 e.printStackTrace();227 220 } catch (IOException e) { 228 221 e.printStackTrace(); 229 } finally {230 if (httpQuery != null)231 httpQuery.releaseConnection();232 222 } 233 223 return false;
Note:
See TracChangeset
for help on using the changeset viewer.