import httplib
conn = httplib.HTTPConnection(head)
conn.request("HEAD",tail)
res = conn.getresponse()
print res.status
I am currently using this to get the HTTP header code of a file.
However, it seems like this code DOWNLOADS the file, and then gets the code.
However, some files are actually video files…and it would be inefficient for my program to download them.
Is there any way to read the header codes without downloading the file at all?
Unfortunately the HEAD HTTP Method like all other HTTP method is just a directive to the server. The HTTP spec says that the server must not return the body in case, but if the server is not implemented or configured correctly then it may return the entire contents of the URL.
There are other factors that may be at play here a proxy server either on your end or on the server end could be caching the content (especially if since it is video) and returning it from a cache. Since the data is coming from a cache full respect of the HTTP specification may be missing.