Changeset 852 for java/ModDepotAccess
- Timestamp:
- May 3, 2013, 2:25:21 PM (12 years ago)
- Location:
- java/ModDepotAccess
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
java/ModDepotAccess/.classpath
r748 r852 3 3 <classpathentry kind="src" path="src"/> 4 4 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> 5 <classpathentry kind="lib" path="/_ThirdPartyLibs/httpclient/commons-logging-1.1.1.jar"/>6 <classpathentry kind="lib" path="/_ThirdPartyLibs/httpclient/httpclient-4.2.2.jar"/>7 <classpathentry kind="lib" path="/_ThirdPartyLibs/httpclient/httpcore-4.2.2.jar"/>8 5 <classpathentry kind="lib" path="/_ThirdPartyLibs/JSON-java.jar"/> 9 6 <classpathentry kind="lib" path="/_ThirdPartyLibs/xstream-1.4.3.jar"/> 10 7 <classpathentry combineaccessrules="false" kind="src" path="/HTTPFileDownloader"/> 8 <classpathentry combineaccessrules="false" kind="src" path="/ProxySettings"/> 11 9 <classpathentry kind="output" path="bin"/> 12 10 </classpath> -
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.