[
https://issues.apache.org/jira/browse/NUTCH-1317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13260372#comment-13260372
]
Markus Jelsma commented on NUTCH-1317:
--------------------------------------
That URL is the original example.
I think it's fairly easy to fix. The code in HttpResponse of protocol-http sets
the contentLength to Integer.MAX_VALUE and it is not being set to maxLength if
there is no ContentLength HTTP response header.
{code}
int contentLength = Integer.MAX_VALUE; // get content length
String contentLengthString = headers.get(Response.CONTENT_LENGTH);
if (contentLengthString != null) {
contentLengthString = contentLengthString.trim();
try {
if (!contentLengthString.isEmpty())
contentLength = Integer.parseInt(contentLengthString);
} catch (NumberFormatException e) {
throw new HttpException("bad content length: "+contentLengthString);
}
}
if (http.getMaxContent() >= 0
&& contentLength > http.getMaxContent()) // limit download size
contentLength = http.getMaxContent();
{code}
I believe this code is alright. But when reading the data we might want to add
a check to never exceed maxLength where it is currently not checked if it is
not set properly.
{code}
for (int i = in.read(bytes); i != -1 && length + i <= contentLength; i =
in.read(bytes)) {
out.write(bytes, 0, i);
length += i;
}
{code}
If we add a check here we still allow downloads without ContentLength HTTP
resonse header but read then only up to maxLength bytes. I'll check it out and
likely open a new issue.
> Max content length by MIME-type
> -------------------------------
>
> Key: NUTCH-1317
> URL: https://issues.apache.org/jira/browse/NUTCH-1317
> Project: Nutch
> Issue Type: Improvement
> Components: parser
> Affects Versions: 1.4
> Reporter: Markus Jelsma
> Assignee: Markus Jelsma
> Fix For: 1.6
>
>
> The good old http.content.length directive is not sufficient in large
> internet crawls. For example, a 5MB PDF file may be parsed without issues but
> a 5MB HTML file may time out.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira