Package us.codecraft.webmagic.downloader
Class CustomRedirectStrategy
- java.lang.Object
-
- org.apache.http.impl.client.DefaultRedirectStrategy
-
- org.apache.http.impl.client.LaxRedirectStrategy
-
- us.codecraft.webmagic.downloader.CustomRedirectStrategy
-
- All Implemented Interfaces:
org.apache.http.client.RedirectStrategy
public class CustomRedirectStrategy extends org.apache.http.impl.client.LaxRedirectStrategy
支持post 302跳转策略实现类 HttpClient默认跳转:httpClientBuilder.setRedirectStrategy(new LaxRedirectStrategy()); 上述代码在post/redirect/post这种情况下不会传递原有请求的数据信息。所以参考了下SeimiCrawler这个项目的重定向策略。 原代码地址:https://github.com/zhegexiaohuozi/SeimiCrawler/blob/master/project/src/main/java/cn/wanghaomiao/seimi/http/hc/SeimiRedirectStrategy.java
-
-
Constructor Summary
Constructors Constructor Description CustomRedirectStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.http.client.methods.HttpUriRequest
getRedirect(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context)
-
-
-
Method Detail
-
getRedirect
public org.apache.http.client.methods.HttpUriRequest getRedirect(org.apache.http.HttpRequest request, org.apache.http.HttpResponse response, org.apache.http.protocol.HttpContext context) throws org.apache.http.ProtocolException
- Specified by:
getRedirect
in interfaceorg.apache.http.client.RedirectStrategy
- Overrides:
getRedirect
in classorg.apache.http.impl.client.DefaultRedirectStrategy
- Throws:
org.apache.http.ProtocolException
-
-