Httpclient 4, error 302. How to redirect?

前端 未结 7 2033
忘了有多久
忘了有多久 2020-11-27 03:03

I want to access one site that first requires an (tomcat server) authentication and then log in with a POST request and keep that user to see the site\'s pages. I use Httpcl

7条回答
  •  旧巷少年郎
    2020-11-27 03:56

    In later versions of HttpCLient (4.1+), you can just do this:

    DefaultHttpClient client = new DefaultHttpClient()
    client.setRedirectStrategy(new LaxRedirectStrategy())
    

    LaxRedirectStrategy will automatically redirect HEAD, GET, and POST requests. For a stricter implementation, use DefaultRedirectStrategy.

提交回复
热议问题