Put this request with Python httplib

倾然丶 夕夏残阳落幕 提交于 2019-12-13 04:22:41

问题


I want to put a request to HDFS REST API.

It works in the RESTClient.

But it failed when i translate it to Python edition( python httplib).

And i can't use this in Curl for some reason.

Anybody know httplib put, can help me translate it to Python edition?

Here is the RESTClient edition:

method: PUT

URL: http://www.somedomain.com:50070/webhdfs/v1/levi/4?op=CREATE


回答1:


With Requests:

import requests
requests.put('http://www.somedomain.com:50070/webhdfs/v1/levi/4?op=CREATE')

With httplib:

import httplib

connection =  httplib.HTTPConnection('www.somedomain.com:50070')
connection.request('PUT', '/webhdfs/v1/levi/4?op=CREATE')

response = connection.getresponse()


来源:https://stackoverflow.com/questions/15716303/put-this-request-with-python-httplib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!