[英]Get redirect Uri from apache HttpResponse java
The librarian method returns the apache HttpResponse object. librarian方法返回apache HttpResponse对象。 I need to get the redirection Uri. 我需要重定向Uri。 How can I do that? 我怎样才能做到这一点?
我想你可以使用Location
头:
response.getLastHeader("Location").getValue();
To get redirect Uri you have to do 2 things: 要重定向Uri,您必须做两件事:
Set redirecting to your HttpClient instance: 设置重定向到您的HttpClient实例:
HttpClient httpclient = getNewHttpClient(); HttpClient httpclient = getNewHttpClient(); HttpClientParams.setRedirecting(httpclient.getParams(), false); HttpClientParams.setRedirecting(httpclient.getParams(),false); // necessary to detect redirection //检测重定向所必需的
Get redirection Uri from HttpResponse instance after request: 请求后从HttpResponse实例获取重定向Uri:
response.getLastHeader("Location").getValue(); response.getLastHeader( “位置”)的getValue()。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.