Commit fe6d9bb2 authored by yihua.huang's avatar yihua.huang

get keep-alive rework

parent fd6d2fd6
......@@ -9,6 +9,7 @@ import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.RequestBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Request;
......@@ -133,7 +134,8 @@ public class HttpClientDownloader implements Downloader {
} finally {
try {
if (httpResponse != null) {
httpResponse.close();
//ensure the connection is released back to pool
EntityUtils.consume(httpResponse.getEntity());
}
} catch (IOException e) {
logger.warn("close response fail", e);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment