throw an exception when needed, prevents html error pages parsing

This commit is contained in:
Athou
2013-04-23 09:14:18 +02:00
parent 92e76d469f
commit 29b3b92b85

View File

@@ -97,12 +97,19 @@ public class HttpGetter {
HttpResponse response = null;
try {
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();
} else if (code >= 300) {
throw new HttpResponseException(code,
"Server returned HTTP error code " + code);
}
} catch (HttpResponseException e) {
if (e.getStatusCode() == HttpStatus.SC_NOT_MODIFIED) {
throw new NotModifiedException();
} else {
throw e;
}
}
Header lastModifiedHeader = response