java.io.IOException: Invalid Http response

与世无争的帅哥 提交于 2019-12-10 16:16:32

问题


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();
    }
}

THE ERROR:

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.


回答1:


You should URL encode the String The Hobbit: The Desolation of Smaug, since you have special character there. Ex : space.




回答2:


I suspect it tripped on the colon (:) not the space. Are there other titles with a colon?



来源:https://stackoverflow.com/questions/22165783/java-io-ioexception-invalid-http-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!