demo_requests_post_headers.py:
import requests url = 'https://begtut.com/try/demopage.html' myobj = {'somekey': 'somevalue'} #use the 'headers' parameter to set the HTTP headers: x = requests.post(url, data = myobj, headers = {"HTTP_HOST": "MyVeryOwnHost"}) print(x.text) #the 'demopage.html' prints all HTTP Headers
➜ begtut>python demo_requests_post_headers.py
HTTP_CONNECTION:keep-alive
HTTP_ACCEPT:*/*
HTTP_ACCEPT_ENCODING:gzip, deflate
HTTP_HOST:MyVeryOwnHost
HTTP_USER_AGENT:python-requests/2.22.0