I have the following code but httplib still treats the header 'emptyheader' as key:value pair.
h = httplib.HTTPConnection("somewhere:5000")
headers = {}
headers['emptyheader'] = None
h.request('POST', '/somewhere', '', headers)
How do I send the sane request but with a valueless header 'emptyheader'?
No way to do it using httplib. 'headers' parameter must be a dictionary. httplib then constructs headers as colon-separated name-value pairs.
And I think requests module does the same thing.
So, as an option, try curl:
subprocess.call(['curl', '-i', '-H', '"emptyheader"', '"http://somewhere:5000/somewhere"'])
But, I'm not sure why do you need it: http headers are key:value pairs by design.