title: How can I set an arbitary Host header in Python 3 urllib?
body: <p>For example, I would like to send a request to <code>12.34.56.78</code> with host header <code>stackoverflow.com</code>. However, Python seems to overwrite the Host header, and the actual packet sent still has <code>Host: 12.34.56.78</code>. </p>
  
  <p>How can I stop this behavior? </p>
  
  <pre><code>from urllib import request
  a = request.build_opener()
  a.addheaders.append(('Host', 'stackoverflow.com'))
  a.open('http://12.34.56.78/')
  </code></pre>
  
  <p>Note: the code runs on Python 3</p>