hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "小学园PHP" <xxy-...@qq.com>
Subject Python httplib and WebHDFS
Date Thu, 28 Mar 2013 02:22:18 GMT
For some reasons, i need use the Python httplib module instead of pycurl.


Here is my code:
import httplib
import urllib


params=urllib.urlencode({"@op":"CREATE","@user.name":"levi"})
headers={"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
conn=httplib.HTTPConnection("localhost:50070")
conn.request("PUT","/webhdfs/v1/levi/7.txt",params,headers)
response=conn.getresponse()
print response.status, response.reason
data=response.read()




OK, but my return is:
#print response.status, response.reason
500 Internal Server Error
#print data
'{"RemoteException":{"exception":"WebApplicationException","javaClassName":"javax.ws.rs.WebApplicationException","message":null}}'


Who knows why? It's OK when i use curl, so where is the problem in httplib method?
Or some other reasons?
Mime
View raw message