How can I read()/write() against a python HTTPConnection?
Question
I've got python code of the form:
(o,i) = os.popen2 ("/usr/bin/ssh host executable")
ios = IOSource(i,o)
Library code then uses this IOSource, doing writes() and read()s against inputstream i and outputstream o.
Yes, there is IPC going on here.. Think RPC.
I want to do this, but in an HTTP fashion rather than spawning an ssh.
I've done python http before with:
conn=httplib.HTTPConnection('localhost',8000)
conn.connect()
conn.request('POST','/someurl/')
response=conn.getresponse()
How do I get the inputstream/outputstream from the HTTPConnection so that my lib code can read from/write to just like the ssh example above?
Solution
for output:
output = response.read()
http://docs.python.org/library/httplib.html#httpresponse-objects
for input: pass your data in the POST body of your request
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow