im trying to get the last-modified date from an apk file on my server, the problem as soon as i try to get the header it fails somehow.
i can download the file fine with
try {
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection con = (HttpURLConnection) new URL(params[0]).openConnection();
con.setRequestMethod("HEAD");
return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
} // do some more not relevant
but as soon as i try to get the header from the server it fails
URL obj = new URL(customURL);
URLConnection conn = obj.openConnection();
Map<String, List<String>> map = conn.getHeaderFields();
for (Map.Entry<String, List<String>> entry : map.entrySet()) {
System.out.println("Key : " + entry.getKey()
+ " ,Value : " + entry.getValue());
Toast.makeText(getApplicationContext(),"Key: "+entry.getKey() + "Value: " + entry.getValue(),Toast.LENGTH_SHORT).show();
}
i have tried this but also to use the already existing connecting and just use the con .. but it all fails somehow
any help would be really nice