【发布时间】:2013-11-05 21:47:20
【问题描述】:
大家好,我在下载管理器项目中工作。
我正在测试一些链接并且工作正常,但是我发现了一个问题
以下这两个链接来自emupardise,我将使用它来说明我的观点。
如果我使用此代码:
String GameLink = "http://www.emuparadise.me/roms/get-download.php?gid=43269&token=2f91d51fcd8b90cec75193ffd592f07c&mirror_available=true";
// String GameLink = "http://www.emuparadise.me/roms/get-download.php?gid=43270&token=a6f395885bea3bbef73d972804d2cbdb&mirror_available=true";
try {
URL url = new URL(GameLink);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestProperty("Host" ,"www.emuparadise.me");
con.setRequestProperty("Accept" ,"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
con.setRequestProperty("Accept-Encoding" ,"gzip, deflate");
con.setRequestProperty("Referer" ,"www.emuparadise.me");
con.setRequestProperty("Connection" ,"keep-alive");
System.out.println("Server answer :"+ con.getResponseCode());
con.connect();
InputStream is = con.getInputStream();
System.out.println(con.getURL().toString()+"\n");
is.close();
} catch (IOException ex) {
Logger.getLogger(Question.class.getName()).log(Level.SEVERE, null, ex);
}
首先我得到:
“服务器答案:200”(如我所愿),但是使用我得到的第二个链接:
"Server answer :-1" 然后我得到错误:java.io.IOException: Invalid Http response
我已经检查了两个页面的标题,它们是相同的,除了两个链接都可以在 Internet 下载管理器中工作,谁能给我一个解决方案?
非常感谢您的宝贵时间
【问题讨论】:
标签: java httpurlconnection getresponse