tags:

views:

446

answers:

1

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?

+1  A: 

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

Corey Goldberg