2

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?

4

1 に答える 1

1

出力用:

output = response.read()

http://docs.python.org/library/httplib.html#httpresponse-objects

入力用: リクエストの POST 本文にデータを渡します

于 2009-05-20T18:42:41.817 に答える