|
1 | 1 | package us.codecraft.webmagic.downloader;
|
2 | 2 |
|
3 |
| -import org.apache.http.*; |
| 3 | +import org.apache.http.HttpException; |
| 4 | +import org.apache.http.HttpRequest; |
| 5 | +import org.apache.http.HttpRequestInterceptor; |
4 | 6 | import org.apache.http.client.CookieStore;
|
5 |
| -import org.apache.http.client.protocol.ResponseContentEncoding; |
6 | 7 | import org.apache.http.config.Registry;
|
7 | 8 | import org.apache.http.config.RegistryBuilder;
|
8 | 9 | import org.apache.http.config.SocketConfig;
|
@@ -66,24 +67,6 @@ public void process(
|
66 | 67 | }
|
67 | 68 | SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true).setTcpNoDelay(true).build();
|
68 | 69 | 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 |
| - }); |
87 | 70 | if (site != null) {
|
88 | 71 | httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(site.getRetryTimes(), true));
|
89 | 72 | }
|
|
0 commit comments