2 zjz 52 zjz_52 于 2014.04.10 22:51 提问

Httpclient4.3.1 关于禁止自动跳转

我想获得header中location的地址,禁止自动跳转的方式 我从网上看到的是httpClient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,false);
但是看api文档,上面说getParams()
Deprecated.
(4.3) use RequestConfig.
怎么用requestconfig来禁止跳转,求指导

2个回答

pan_de
pan_de   2015.04.01 16:58
         HttpGet get = new HttpGet(url);
        RequestConfig requestConfig = RequestConfig.custom().setRedirectsEnabled(false).build();
        get.setConfig(requestConfig);
lx_0515
lx_0515   2015.11.13 14:04

HttpGet httpGet = new HttpGet(url);
RequestConfig requestConfig = RequestConfig.custom().setRedirectsEnabled(false).build();
httpGet.setConfig(requestConfig);

Csdn user default icon
上传中...
上传图片
插入图片