I am currently using the python library httplib to pass POST requests to a cgi script.
# Make web call to CGI script
user_agent = r'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
headers = {'User-Agent' : user_agent,
"Content-type": "application/x-www-form-urlencoded",
"Accept": "text/plain"}
conn = httplib.HTTPConnection(self.host)
conn.request("POST", "/path/cgi_script.py", params, headers)
response = conn.getresponse()
if debug: print response.status, response.reason
However, the httplib library is old, and I would like to uses requests, which is newer. How can I refactor my code to use requests? I have been looking online for an example, but I cannot find any.