mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
disable http retry manager
This commit is contained in:
@@ -14,6 +14,7 @@ import org.apache.http.client.methods.HttpGet;
|
|||||||
import org.apache.http.client.params.CookiePolicy;
|
import org.apache.http.client.params.CookiePolicy;
|
||||||
import org.apache.http.client.params.HttpClientParams;
|
import org.apache.http.client.params.HttpClientParams;
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
|
||||||
import org.apache.http.params.HttpConnectionParams;
|
import org.apache.http.params.HttpConnectionParams;
|
||||||
import org.apache.http.params.HttpParams;
|
import org.apache.http.params.HttpParams;
|
||||||
import org.apache.http.params.HttpProtocolParams;
|
import org.apache.http.params.HttpProtocolParams;
|
||||||
@@ -51,6 +52,9 @@ public class HttpGetter {
|
|||||||
HttpProtocolParams.setContentCharset(params, "UTF-8");
|
HttpProtocolParams.setContentCharset(params, "UTF-8");
|
||||||
HttpConnectionParams.setConnectionTimeout(params, 4000);
|
HttpConnectionParams.setConnectionTimeout(params, 4000);
|
||||||
HttpConnectionParams.setSoTimeout(params, 4000);
|
HttpConnectionParams.setSoTimeout(params, 4000);
|
||||||
|
httpclient
|
||||||
|
.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(
|
||||||
|
0, false));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HttpGet httpget = new HttpGet(url);
|
HttpGet httpget = new HttpGet(url);
|
||||||
@@ -78,26 +82,26 @@ public class HttpGetter {
|
|||||||
Header lastModifiedHeader = response
|
Header lastModifiedHeader = response
|
||||||
.getFirstHeader(HttpHeaders.LAST_MODIFIED);
|
.getFirstHeader(HttpHeaders.LAST_MODIFIED);
|
||||||
Header eTagHeader = response.getFirstHeader(HttpHeaders.ETAG);
|
Header eTagHeader = response.getFirstHeader(HttpHeaders.ETAG);
|
||||||
HttpEntity entity = response.getEntity();
|
|
||||||
|
|
||||||
String lastModifiedResponse = lastModifiedHeader == null ? null
|
String lastModifiedResponse = lastModifiedHeader == null ? null
|
||||||
: lastModifiedHeader.getValue();
|
: lastModifiedHeader.getValue();
|
||||||
String eTagResponse = eTagHeader == null ? null : eTagHeader
|
|
||||||
.getValue();
|
|
||||||
|
|
||||||
if (lastModified != null
|
if (lastModified != null
|
||||||
&& StringUtils.equals(lastModified, lastModifiedResponse)) {
|
&& StringUtils.equals(lastModified, lastModifiedResponse)) {
|
||||||
throw new NotModifiedException();
|
throw new NotModifiedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String eTagResponse = eTagHeader == null ? null : eTagHeader
|
||||||
|
.getValue();
|
||||||
if (eTag != null && StringUtils.equals(eTag, eTagResponse)) {
|
if (eTag != null && StringUtils.equals(eTag, eTagResponse)) {
|
||||||
throw new NotModifiedException();
|
throw new NotModifiedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HttpEntity entity = response.getEntity();
|
||||||
byte[] content = null;
|
byte[] content = null;
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
content = EntityUtils.toByteArray(entity);
|
content = EntityUtils.toByteArray(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
long duration = System.currentTimeMillis() - start;
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user