video url Http error 405 can't download
Emily Wong
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", "");