Skip to content

Commit

Permalink
Merge pull request yasserg#74 from albert0815/albert0815-close-entity
Browse files Browse the repository at this point in the history
Fix for issue yasserg#52 - Close entity when page is to big
  • Loading branch information
yasserg committed Jun 1, 2015
2 parents be02e29 + 4fd9c84 commit de46d30
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/edu/uci/ics/crawler4j/fetcher/PageFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import edu.uci.ics.crawler4j.crawler.authentication.NtAuthInfo;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.auth.AuthScope;
Expand Down Expand Up @@ -234,7 +234,7 @@ public PageFetchResult fetchPage(WebURL webUrl)
lastFetchTime = (new Date()).getTime();
}

HttpResponse response = httpClient.execute(request);
CloseableHttpResponse response = httpClient.execute(request);
fetchResult.setEntity(response.getEntity());
fetchResult.setResponseHeaders(response.getAllHeaders());

Expand Down Expand Up @@ -274,6 +274,8 @@ public PageFetchResult fetchPage(WebURL webUrl)
}
}
if (size > config.getMaxDownloadSize()) {
//fix issue #52 - consume entity
response.close();
throw new PageBiggerThanMaxSizeException(size);
}
}
Expand Down Expand Up @@ -307,4 +309,4 @@ protected HttpUriRequest newHttpUriRequest(String url) {
return new HttpGet(url);
}

}
}

0 comments on commit de46d30

Please sign in to comment.