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