from io import BytesIO
import pycurl
import json
-import yaml
from osmclient.common import http
-from osmclient.common.exceptions import ClientException
class Http(http.Http):
curl_cmd.close()
# TODO 202 accepted should be returned somehow
if data.getvalue():
- return http_code, json.loads(data.getvalue().decode())
+ return http_code, data.getvalue().decode()
else:
return http_code, None
data = BytesIO()
curl_cmd = self._get_curl_cmd(endpoint)
if put_method:
- curl_cmd.setopt(pycurl.PUT, 1)
+ curl_cmd.setopt(pycurl.CUSTOMREQUEST, "PUT")
elif patch_method:
curl_cmd.setopt(pycurl.CUSTOMREQUEST, "PATCH")
- else:
- curl_cmd.setopt(pycurl.POST, 1)
+ curl_cmd.setopt(pycurl.POST, 1)
curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write)
if postfields_dict is not None:
(pycurl.FORM_FILE,
formfile[1])))])
elif filename is not None:
- with open(filename, 'r') as stream:
+ with open(filename, 'rb') as stream:
postdata=stream.read()
curl_cmd.setopt(pycurl.POSTFIELDS, postdata)