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; 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