near empty pages count as empty, too

git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@356 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
andreas.schildbach 2010-11-14 11:27:57 +00:00
parent a250daa67b
commit 08e83d4a4d

View file

@ -48,6 +48,7 @@ public final class ParserUtils
private static final int SCRAPE_CONNECT_TIMEOUT = 5000;
private static final int SCRAPE_READ_TIMEOUT = 15000;
private static final String SCRAPE_DEFAULT_ENCODING = "ISO-8859-1";
private static final int SCRAPE_PAGE_EMPTY_THRESHOLD = 2;
private static String stateCookie;
@ -111,7 +112,7 @@ public final class ParserUtils
copy(pageReader, buffer);
pageReader.close();
if (buffer.length() > 0)
if (buffer.length() > SCRAPE_PAGE_EMPTY_THRESHOLD)
{
if (cookieHandling)
{
@ -134,10 +135,11 @@ public final class ParserUtils
}
else
{
final String message = "got empty page (length: " + buffer.length() + ")";
if (tries-- > 0)
System.out.println("got empty page, retrying...");
System.out.println(message + ", retrying...");
else
throw new IOException("got empty page: " + url);
throw new IOException(message + ": " + url);
}
}
catch (final SocketTimeoutException x)