Preventing HttpClient 4 from following redirect

后端 未结 5 1421
礼貌的吻别
礼貌的吻别 2020-12-01 14:19

I\'m connecting to my AppEngine application using the Apache HttpComponents library. In order to authenticate my users, I need to pass an authentication token along to the

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 15:12

    You can do it with the http params:

    final HttpParams params = new BasicHttpParams();
    HttpClientParams.setRedirecting(params, false);
    

    The method has no javadoc, but if you look at the source you can see it sets:

    HANDLE_REDIRECTS

    which controls:

    Defines whether redirects should be handled automatically

提交回复
热议问题