What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if http://somedomain/foo/ will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without having to download the content. Does anyone know of an easy way of doing this?
I have found that httplib is slightly faster than urllib2.  I timed two programs - one using httplib  and the other using urllib2 - sending HEAD requests to 10,000 URL's.  The httplib one was faster by several minutes.  httplib's total stats were: real    6m21.334s
                                                                    user    0m2.124s
                                                                    sys     0m16.372s
And urllib2's total stats were:                                 real    9m1.380s
                                                                    user    0m16.666s
                                                                    sys     0m28.565s
Does anybody else have input on this?
How do you send a HEAD HTTP request in Python 2?