The common examples for okhttp cover the scenarios of get and post.
But I need to get the file size of a file with a url. Since I need to inform the the user, and only after getting their approval to download the file.
Currently I am using this code
URL url = new URL("http://server.com/file.mp3");
URLConnection urlConnection = url.openConnection();
urlConnection.connect();
int file_size = urlConnection.getContentLength();
mentioned in this stackoverflow question How to know the size of a file before downloading it?
Which works but as I am using okhttp in my project for other get requests I was hoping to use it for this scenario also.