Video Url Http Error 405 Can't Download

I have an online video url, I can use vitamio video player play it online, but once I use android HttpUrlConnection download, I failed and received http 405 error.Can anyone give me some help?

 HttpURLConnection conn = null;
 int totalSize = 0;
 conn = (HttpURLConnection) new URL(url).openConnection();
 conn.setConnectTimeout(10 * 1000);
 conn.setRequestMethod("GET");
 conn.connect();
 totalSize = conn.getContentLength();

 [1]:

the url is [the url of a video][1] I put the url on , it displayed right length which is 71917427.

1 Answer

This problem was finally solved by add userAgent:

conn.setRequestProperty("User-agent", "");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest