mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
store duration of fetching
This commit is contained in:
@@ -43,6 +43,7 @@ public class HttpGetter {
|
|||||||
public HttpResult getBinary(String url, String lastModified, String eTag)
|
public HttpResult getBinary(String url, String lastModified, String eTag)
|
||||||
throws ClientProtocolException, IOException, NotModifiedException {
|
throws ClientProtocolException, IOException, NotModifiedException {
|
||||||
HttpResult result = null;
|
HttpResult result = null;
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
DefaultHttpClient httpclient = new DefaultHttpClient();
|
DefaultHttpClient httpclient = new DefaultHttpClient();
|
||||||
HttpParams params = httpclient.getParams();
|
HttpParams params = httpclient.getParams();
|
||||||
@@ -97,9 +98,10 @@ public class HttpGetter {
|
|||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
content = EntityUtils.toByteArray(entity);
|
content = EntityUtils.toByteArray(entity);
|
||||||
}
|
}
|
||||||
|
long duration = System.currentTimeMillis() - start;
|
||||||
result = new HttpResult(content, lastModifiedHeader == null ? null
|
result = new HttpResult(content, lastModifiedHeader == null ? null
|
||||||
: lastModifiedHeader.getValue(), eTagHeader == null ? null
|
: lastModifiedHeader.getValue(), eTagHeader == null ? null
|
||||||
: eTagHeader.getValue());
|
: eTagHeader.getValue(), duration);
|
||||||
} finally {
|
} finally {
|
||||||
httpclient.getConnectionManager().shutdown();
|
httpclient.getConnectionManager().shutdown();
|
||||||
}
|
}
|
||||||
@@ -111,11 +113,14 @@ public class HttpGetter {
|
|||||||
private byte[] content;
|
private byte[] content;
|
||||||
private String lastModifiedSince;
|
private String lastModifiedSince;
|
||||||
private String eTag;
|
private String eTag;
|
||||||
|
private long duration;
|
||||||
|
|
||||||
public HttpResult(byte[] content, String lastModifiedSince, String eTag) {
|
public HttpResult(byte[] content, String lastModifiedSince,
|
||||||
|
String eTag, long duration) {
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.lastModifiedSince = lastModifiedSince;
|
this.lastModifiedSince = lastModifiedSince;
|
||||||
this.eTag = eTag;
|
this.eTag = eTag;
|
||||||
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getContent() {
|
public byte[] getContent() {
|
||||||
@@ -130,6 +135,10 @@ public class HttpGetter {
|
|||||||
return eTag;
|
return eTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getDuration() {
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NotModifiedException extends Exception {
|
public static class NotModifiedException extends Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user