Using python-requests and python-magic, I would like to test the mime-type of a web resource without fetching all its content (especially if this resource happens to be eg.
if 'content-type' suffices, you can issue an HTTP 'Head' request instead of 'Get', to just receive the HTTP headers.
import requests url = 'http://www.december.com/html/demo/hello.html' response = requests.head(url) print response.headers['content-type']