title: Using urllib2 cannot change HTTP method to PUT
body: <p>Why can I not change method to PUT.  Can I change to PUT without too many code changes?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>cj = cookielib.CookieJar()
  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  urllib2.install_opener(opener)   
  
  #code to change method to PUT
  opener.get_method = lambda: 'PUT'
  
  print "now using method:", meth  # prints now using PUT
  
  try:
      r = opener.open("http://the_url")
  except urllib2.HTTPError as e:
      if hasattr(e, 'code'):
          report += "HTTP error status " + str(e.code) + " FAIL\n"
          if hasattr(e, 'reason'):
              print "HTTP Error reason " + e.reason
      else:
          report += "HTTP error occurred FAIL\n"
  </code></pre>
  
  <p>But I get runtime error
  HTTP Error reason Request method 'POST' not supported
  PUT session test
  HTTP error status 405 FAIL</p>