X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fsol005%2Fhttp.py;h=f19a098b55221a7b6f52637e474139c367b58a65;hb=d8cf387ce15e74c4c13d966ecc146499e2c37684;hp=5311ca8d1e5b6cda544e662861c89250fd631b0f;hpb=98213d0b29e9a26d113eaced1e0975a1d2ce833c;p=osm%2Fosmclient.git diff --git a/osmclient/sol005/http.py b/osmclient/sol005/http.py index 5311ca8..f19a098 100644 --- a/osmclient/sol005/http.py +++ b/osmclient/sol005/http.py @@ -17,9 +17,7 @@ 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): @@ -31,7 +29,7 @@ class Http(http.Http): def _get_curl_cmd(self, endpoint): curl_cmd = pycurl.Curl() - #print self._url + endpoint + #print(self._url + endpoint) curl_cmd.setopt(pycurl.URL, self._url + endpoint) curl_cmd.setopt(pycurl.SSL_VERIFYPEER, 0) curl_cmd.setopt(pycurl.SSL_VERIFYHOST, 0) @@ -46,7 +44,7 @@ class Http(http.Http): curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write) curl_cmd.perform() http_code = curl_cmd.getinfo(pycurl.HTTP_CODE) - #print 'HTTP_CODE: {}'.format(http_code) + #print('HTTP_CODE: {}'.format(http_code)) curl_cmd.close() # TODO 202 accepted should be returned somehow if data.getvalue(): @@ -60,11 +58,10 @@ class Http(http.Http): 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: @@ -77,7 +74,7 @@ class Http(http.Http): (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)