Class 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
    • Field Summary

      • Fields inherited from class org.apache.http.impl.client.LaxRedirectStrategy

        INSTANCE
      • Fields inherited from class org.apache.http.impl.client.DefaultRedirectStrategy

        REDIRECT_LOCATIONS, SC_PERMANENT_REDIRECT
    • 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)  
      • Methods inherited from class org.apache.http.impl.client.DefaultRedirectStrategy

        createLocationURI, getLocationURI, isRedirectable, isRedirected
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CustomRedirectStrategy

        public CustomRedirectStrategy()
    • 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 interface org.apache.http.client.RedirectStrategy
        Overrides:
        getRedirect in class org.apache.http.impl.client.DefaultRedirectStrategy
        Throws:
        org.apache.http.ProtocolException