I need to use the python httplib.
And i code two sample, the first works, not the second.
But what i need is the second.
In the second sample, the data seems not be sent correctly.
I want to know where is the problem in the second.
TIA, Levi
Here is my two code:
first sample:
conn=httplib.HTTPConnection(data_host) a_file=open("/home/levi/5","rb")
data=a_file.read() a_file.close() conn.request("PUT",
"/webhdfs/v1/levi/5?op=CREATE&user.name=levi", data) res=conn.getresponse()
print res.status,res.reason print res.msg conn.close()
And the second:
conn=httplib.HTTPConnection(data_host) conn.connect()
conn.putrequest("PUT","/webhdfs/v1/levi/5?op=CREATE&user.name=levi")
conn.endheaders() a_file=open("/home/levi/5","rb") data=a_file.read()
a_file.close() conn.send(data) res=conn.getresponse() print
res.status,res.reason print res.read() print res.msg conn.close()
--
http://mail.python.org/mailman/listinfo/python-list