You want to actually tell the server not to send the full contents of the file. HTTP has a mechanism for this called "HEAD", which is an alternative to "GET". It works the same way, but the server sends you headers, none of the actual content.
This will save at least one of your bandwidths, while just not doing read () will not bother getting the full file.
Try the following:
import httplib c = httplib.HTTPConnection(<hostname>) c.request("HEAD", <url>) print c.getresponse().status
A status code will be printed. Url should be only a segment, for example "/ foo", and the host name should be "www.example.com".
source share