Curl和jersey客户端给出不同的状态调用随机重定向服务

时间:2015-05-25 13:01:25

标签: java rest curl jersey

我正在尝试获取下面的url,它生成随机URL。我看到2个针对curl和jersey客户端的不同响应

http://www.randomwebsite.com/cgi-bin/random.pl 

curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET http://www.randomwebsite.com/cgi-bin/random.pl
HTTP/1.1 302 Found
Server: nginx
Date: Mon, 25 May 2015 12:05:33 GMT
Content-Type: text/html; charset=iso-8859-1
Location: http://www.copvcia.com/
ngpass_ngall: 1
Content-Length: 207
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.copvcia.com/">here</a>.</p>
</body></html>

以下代码的针对泽西客户端的响应。它包含不同的响应,但它们不匹配

Client client = Client.create();
            WebResource webResource2 = client.resource("http://www.randomwebsite.com/cgi-bin/random.pl");
            //client.setFollowRedirects(false);
            ClientResponse response2 = webResource2.accept("application/json").type(MediaType.APPLICATION_JSON).get(ClientResponse.class);


            System.out.println(response2);


            String output2 = response2.getEntity(String.class);
            System.out.println("\n============getFtoCResponse============");
            System.out.println(output2);



GET http://78rpm.blogspot.in/ returned a response status of 200 OK

============getFtoCResponse============
<!DOCTYPE html>
<html class='v2' dir='ltr'>
<head>
<meta content='width=1100' name='viewport'/>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<script type="text/javascript">(function() { var b=window,f="chrome",g="tick",k="jstiming";(function(){function d(a){this.t={};this.tick=function(a,d,c){var e=void 0!=c?c:(new Date).getTime();this.t[a]=[e,d];if(void 0==c)try{b.console.timeStamp("CSI/"+a)}catch(h){}};this[g]("start",null,a)}var a;b.performance&&(a=b.performance.timing);var n=a?new d(a.responseStart):new d;b.jstiming={Timer:d,load:n};if(a){var c=a.navigationStart,h=a.responseStart;0<c&&h>=c&&(b[k].srt=h-c)}if(a){var e=b[k].load;0<c&&h>=c&&(e[g]("_wtsrt",void 0,c),e[g]("wtsrt_","_wtsrt",h),e[g]("tbsd_","wtsrt_"))}try{a=null,
b[f]&&b[f].csi&&(a=Math.floor(b[f].csi().pageT),e&&0<c&&(e[g]("_tbnd",void 0,b[f].csi().startE),e[g]("tbnd_","_tbnd",c))),null==a&&b.gtbExternal&&(a=b.gtbExternal.pageT()),null==a&&b.external&&(a=b.external.pageT,e&&0<c&&(e[g]("_tbnd",void 0,b.external.startE),e[g]("tbnd_","_tbnd",c))),a&&(b[k].pt=a)}catch(p){}})();b.tickAboveFold=function(d){var a=0;if(d.offsetParent){do a+=d.offsetTop;while(d=d.offsetParent)}d=a;750>=d&&b[k].load[g]("aft")};var l=!1;function m(){l||(l=!0,b[k].load[g]("firstScrollTime"))}b.addEventListener?b.addEventListener("scroll",m,!1):b.attachEvent("onscroll",m);
 })();</script>
<meta content='blogger' name='generator'/>
<link href='http://78rpm.blogspot.in/favicon.ico' rel='icon' type='image/x-icon'/>
<link href='http://78rpm.blogspot.com/' rel='canonical'/>
<link rel="alternate" type="application/atom+xml" title="78rpm - Atom" href="http://78rpm.blogspot.com/feeds/posts/default" />
<link rel="alternate" type="application/rss+xml" title="78rpm - RSS" href="http://78rpm.blogspot.com/feeds/posts/default?alt=rss" />
<link rel="service.post" type="application/atom+xml" title="78rpm - Atom" href="http://www.blogger.com/feeds/8790377728438814374/posts/default" />

0 个答案:

没有答案