I’m trying to connect on a valid URL using the following code, but I got a 404 Error…
URL url = new URL(urlString);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.setConnectTimeout(ConnectivityHelper.CONNECT_TIMEOUT);
urlConnection.setReadTimeout(ConnectivityHelper.READ_TIMEOUT);
urlConnection.setRequestProperty("Accept-Encoding", "gzip, deflate");
When I call
urlConnection.getInputStream()
I got a crash, because the httpResponse code was 404
What I don’t understand is that the url does exists: http://www.plongeurs.tv/xml/itunes.xml
I trace it using wget and I got
--2012-07-01 16:24:52-- http://www.plongeurs.tv/xml/itunes.xml
Résolution de www.plongeurs.tv (www.plongeurs.tv)... 94.23.134.238
Connexion vers www.plongeurs.tv (www.plongeurs.tv)|94.23.134.238|:80... connecté.
requête HTTP transmise, en attente de la réponse... 200 OK
How come I get a 404 error in my app ?
FYI this is the only url I found having this problem, after testing it with 1000+ rss feeds
I don’t believe it, I just tried it specifying a user-agent and now it works !
connection.setRequestProperty (“User-agent”, “mozilla”);