问题描述
在网络中,我在每个新的浏览器会话中都会自动进行身份验证,这大约需要10秒和两次重定向(我认为是Javascript)。 如何设置HttpClient遵循这些重定向?
这不起作用:
HttpHost proxy = new HttpHost("172.125.166.5", 8080, "http");
DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
CloseableHttpClient httpClient = HttpClients.custom().setRoutePlanner(routePlanner).setRedirectStrategy(new LaxRedirectStrategy()).build();
1楼
您将需要阅读响应并提取重定向URL并使用这些URL执行新请求。 但是,这对于使用更复杂的身份验证方法(可能需要浏览器插件或SSL证书)的身份验证是不够的。