我正在调用一个url链接,该链接将重定向到随机网址页面。当我点击卷曲时,我的响应如下所示
curl -i -H "Accept: application/html" -H -L "Content-Type: application/html" -X GET http://www.randomwebsite.com/cgi-bin/random.pl
HTTP/1.1 302 Found
Server: nginx
Date: Mon, 25 May 2015 13:22:36 GMT
Content-Type: text/html; charset=iso-8859-1
Location: http://www.straightdope.com
ngpass_ngall: 1
Content-Length: 211
Age: 0
Via: 1.1 localhost.localdomain
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://www.straightdope.com">here</a>.</p>
</body></html>
但是,当我通过泽西客户端时,我无法看到html文档响应,我得到低于响应
GET http://www.randomwebsite.com/cgi-bin/random.pl returned a response status of 302 Found
private void getFtoCResponse() {
try {
Client client = Client.create();
client.setFollowRedirects(false);
WebResource webResource2 = client.resource("http://www.randomwebsite.com/cgi-bin/random.pl");
ClientResponse response2 = webResource2.accept("text/html").get(ClientResponse.class);
//response2.g
System.out.println(response2);
//InputStream stream= response2.getEntityInputStream();
//String myString = IOUtils.toString(stream, "UTF-8");
// System.out.println(myString);
String output2 = response2.getEntity(String.class);
System.out.println("\n============getFtoCResponse============");
System.out.println(output2);
} catch (Exception e) {
e.printStackTrace();
}
}