Android HttpURLConnection只在标题中获取信息,而不是下载

时间:2016-04-19 08:28:28

标签: android httpurlconnection get-headers

我使用HttpUrlConnection从url:https:///abc.com//test.mp4

获取标头
httpConnection = (HttpURLConnection) url.openConnection();
httpConnection.setConnectTimeout(10000);
httpConnection.setReadTimeout(10000);
httpConnection.setRequestMethod(Constants.HTTP.GET);
httpConnection.setRequestProperty("User-Agent", Constants.USER_AGENT);
httpConnection.connect();
final int responseCode = httpConnection.getResponseCode();
// stuck and file downloaded here
// logcat is showing: ssl=0x6bc1ba20 sslRead buf=0x428cf908 len=1500,timeo=100 many time, my phone fetch many many data from network.
// wait a long time before disconnect.
httpConnection.disconnect();
// then I get content length, header,... here

如何在没有下载文件的情况下获取url的标头?感谢

0 个答案:

没有答案