Skip to content

Commit af07280

Browse files
committed
remove defend code for httpclient 4.3.1 because it is fixed in 4.3.3 #59
1 parent b33f84f commit af07280

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientGenerator.java

+3-20
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package us.codecraft.webmagic.downloader;
22

3-
import org.apache.http.*;
3+
import org.apache.http.HttpException;
4+
import org.apache.http.HttpRequest;
5+
import org.apache.http.HttpRequestInterceptor;
46
import org.apache.http.client.CookieStore;
5-
import org.apache.http.client.protocol.ResponseContentEncoding;
67
import org.apache.http.config.Registry;
78
import org.apache.http.config.RegistryBuilder;
89
import org.apache.http.config.SocketConfig;
@@ -66,24 +67,6 @@ public void process(
6667
}
6768
SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true).setTcpNoDelay(true).build();
6869
httpClientBuilder.setDefaultSocketConfig(socketConfig);
69-
// Http client has some problem handling compressing entity for redirect
70-
// So I disable it and do it manually
71-
// https://issues.apache.org/jira/browse/HTTPCLIENT-1432
72-
httpClientBuilder.disableContentCompression();
73-
httpClientBuilder.addInterceptorFirst(new HttpResponseInterceptor() {
74-
75-
private ResponseContentEncoding contentEncoding = new ResponseContentEncoding();
76-
77-
public void process(
78-
final HttpResponse response,
79-
final HttpContext context) throws HttpException, IOException {
80-
if (response.getStatusLine().getStatusCode() == 301 || response.getStatusLine().getStatusCode() == 302) {
81-
return;
82-
}
83-
contentEncoding.process(response, context);
84-
}
85-
86-
});
8770
if (site != null) {
8871
httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(site.getRetryTimes(), true));
8972
}

0 commit comments

Comments
 (0)