How to prevent apache http client from following a redirect

后端 未结 10 1844
独厮守ぢ
独厮守ぢ 2020-11-28 06:08

I\'m connecting to a remote server with apache http client. the remote server sends a redirect, and i want to achieve that my client isn\'t following the redirect automatica

10条回答
  •  攒了一身酷
    2020-11-28 06:52

    This worked for me:

    HttpGet httpGet = new HttpGet("www.google.com");
    HttpParams params = httpGet.getParams();
    params.setParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE);
    httpGet.setParams(params);
    

提交回复
热议问题