java.io.IOException:无效的Http响应 [英] java.io.IOException: Invalid Http response
问题描述
现在,在您说出类似这样的问题之前,我想指出的是,我在大多数情况下都没有碰到运气.我也是这里的第一次来访,所以要保持温柔.
Now before you say there are questions like this I'd like to point out I've looked over most of them without any luck. Also I'm a first timer here so be gentle.
我现在在当前程序中有这种烦恼:
I have this annoyance right now in my current program:
程序的这一部分基本上使用搜索引擎来查找种子文件.
Basically this part of my program uses a search engine to find torrent files.
public static ArrayList<String> search(String args) throws IOException {
args = args.replace(":", "");
ArrayList<String> list = new ArrayList<String>();
URL url = new URL("http://pirateproxy.net/search/" + args + "/");
URLConnection con = url.openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); <---- THIS
}
public static void main(String[] args) {
try {
search("The Hobbit: The Desolation of Smaug");
} catch (IOException e) {
e.printStackTrace();
}
}
错误:
java.io.IOException: Invalid Http response
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at service.ServiceDownloader.search(ServiceDownloader.java:20)
at service.ServiceDownloader.main(ServiceDownloader.java:45)
现在有趣的部分是,这部电影(《霍比特人:史矛革之战》)只错了,其他每部电影都表现完美.我不明白请帮忙. (此外,我已经从搜索方法中删除了所有不必要的代码)
Now the fun part is that it ONLY goes wrong for this movie ("The Hobbit: The Desolation of Smaug"), every other movie works perfectly. I don't understand this. Please do help. (Also I have removed every unnecessary code from the search method)
如果我在此处未提供足够的信息,请询问我更多信息.
If I did not put enough information here please ask me for more.
推荐答案
您应该对字符串The Hobbit: The Desolation of Smaug
进行URL编码,因为那里有特殊字符.例如:空格.
You should URL encode the String The Hobbit: The Desolation of Smaug
, since you have special character there. Ex : space.
这篇关于java.io.IOException:无效的Http响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!