forked from Archives/Athou_commafeed
throw an exception when needed, prevents html error pages parsing
This commit is contained in:
@@ -97,12 +97,19 @@ public class HttpGetter {
|
|||||||
HttpResponse response = null;
|
HttpResponse response = null;
|
||||||
try {
|
try {
|
||||||
response = client.execute(httpget);
|
response = client.execute(httpget);
|
||||||
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_MODIFIED) {
|
int code = response.getStatusLine().getStatusCode();
|
||||||
|
if (code == HttpStatus.SC_NOT_MODIFIED) {
|
||||||
throw new NotModifiedException();
|
throw new NotModifiedException();
|
||||||
|
} else if (code >= 300) {
|
||||||
|
throw new HttpResponseException(code,
|
||||||
|
"Server returned HTTP error code " + code);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (HttpResponseException e) {
|
} catch (HttpResponseException e) {
|
||||||
if (e.getStatusCode() == HttpStatus.SC_NOT_MODIFIED) {
|
if (e.getStatusCode() == HttpStatus.SC_NOT_MODIFIED) {
|
||||||
throw new NotModifiedException();
|
throw new NotModifiedException();
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Header lastModifiedHeader = response
|
Header lastModifiedHeader = response
|
||||||
|
|||||||
Reference in New Issue
Block a user