In Python 3x, how can I get the headers such as content length before downloading a file? This
import urllib.request
aaa, bbb = urllib.request.urlretrieve(url, file_name)
bbb['Content-Length']
# or
ccc, ddd = urllib.request.urlretrieve(url)
ddd['Content-Length']
seems like it's first downloading the whole file and then returns its headers. I think so because it takes plenty of time and returns the name either of the temp file (the 2nd case) or real one (the 1st case).
Or am I wrong?
What I want is to retrieve Content-Lenght first and then, depending on some condition, download and save or not do anything with it.