List of usage examples for org.apache.commons.httpclient.util HttpURLConnection HttpURLConnection
public HttpURLConnection(HttpMethod paramHttpMethod, URL paramURL)
From source file:org.crosswire.common.util.WebResource.java
/** * Determine the size of this WebResource. * <p>Note that the http client may read the entire file to determine this.</p> * * @return the size of the file/*from www .ja v a 2 s. c o m*/ */ public int getSize() { HttpMethod method = new HeadMethod(uri.getPath()); try { // Execute the method. int status = client.executeMethod(method); if (status == HttpStatus.SC_OK) { return new HttpURLConnection(method, NetUtil.toURL(uri)).getContentLength(); } String reason = HttpStatus.getStatusText(status); Reporter.informUser(this, Msg.MISSING_FILE, new Object[] { reason + ':' + uri.getPath() }); } catch (IOException e) { return 0; } finally { // Release the connection. method.releaseConnection(); } return 0; }
From source file:org.crosswire.common.util.WebResource.java
/** * Determine the last modified date of this WebResource. * <p>Note that the http client may read the entire file.</p> * * @return the last mod date of the file */// ww w . j av a2 s .c o m public long getLastModified() { HttpMethod method = new HeadMethod(uri.getPath()); try { // Execute the method. if (client.executeMethod(method) == HttpStatus.SC_OK) { return new HttpURLConnection(method, NetUtil.toURL(uri)).getLastModified(); } } catch (IOException e) { return new Date().getTime(); } finally { // Release the connection. method.releaseConnection(); } return new Date().getTime(); }