You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by 小学园PHP <xx...@qq.com> on 2013/03/28 03:22:18 UTC

Python httplib and WebHDFS

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?