nutch-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Markus Jelsma (JIRA)" <>
Subject [jira] [Commented] (NUTCH-1317) Max content length by MIME-type
Date Tue, 24 Apr 2012 09:13:33 GMT


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.

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

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.

    for (int i =; i != -1 && length + i <= contentLength; i =

      out.write(bytes, 0, i);
      length += i;

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:
>             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:!default.jspa
For more information on JIRA, see:


View raw message