title: Making HTTP HEAD request with urllib2 from Python 2
body: <p>I'm trying to do a HEAD request of a page using Python 2.</p>
  
  <p>I am trying</p>
  
  <pre><code>import misc_urllib2
  .....
  opender = urllib2.build_opener([misc_urllib2.MyHTTPRedirectHandler(), misc_urllib2.HeadRequest()])
  </code></pre>
  
  <p>with <code>misc_urllib2.py</code> containing</p>
  
  <pre><code>class HeadRequest(urllib2.Request):
      def get_method(self):
          return "HEAD"
  
  
  class MyHTTPRedirectHandler(urllib2.HTTPRedirectHandler):
      def __init__ (self):
          self.redirects = []
  
      def http_error_301(self, req, fp, code, msg, headers):  
          result = urllib2.HTTPRedirectHandler.http_error_301(
                  self, req, fp, code, msg, headers)
          result.redirect_code = code
          return result
  
      http_error_302 = http_error_303 = http_error_307 = http_error_301
  </code></pre>
  
  <p>But I am getting</p>
  
  <pre><code>TypeError: __init__() takes at least 2 arguments (1 given)
  </code></pre>
  
  <p>If I just do</p>
  
  <pre><code>opender = urllib2.build_opener(misc_urllib2.MyHTTPRedirectHandler())
  </code></pre>
  
  <p>then it works fine</p>