java.io.IOException: Invalid Http response
Solution 1
You should URL encode the String The Hobbit: The Desolation of Smaug
, since you have special character there. Ex : space.
Solution 2
I suspect it tripped on the colon (:) not the space. Are there other titles with a colon?
AlexP
Updated on June 04, 2022Comments
-
AlexP almost 2 years
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.
-
AlexP about 10 yearsThis works! But I still don't understand why. I've had several other movies with space in it that I didn't need to change for it to work.