Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions pulsar/client/transport/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def execute(self, url, method=None, data=None, input_path=None, output_path=None
if not output_path:
return buf.getvalue()
finally:
c.close()
buf.close()


Expand All @@ -69,13 +70,16 @@ def post_file(url, path):
# wrap it in a better one.
message = NO_SUCH_FILE_MESSAGE % (path, url)
raise Exception(message)
c = _new_curl_object_for_url(url)
c.setopt(c.HTTPPOST, [("file", (c.FORM_FILE, path.encode('ascii')))])
c.perform()
status_code = c.getinfo(HTTP_CODE)
if int(status_code) != 200:
message = POST_FAILED_MESSAGE % (url, status_code)
raise Exception(message)
try:
c = _new_curl_object_for_url(url)
c.setopt(c.HTTPPOST, [("file", (c.FORM_FILE, path.encode('ascii')))])
c.perform()
status_code = c.getinfo(HTTP_CODE)
if int(status_code) != 200:
message = POST_FAILED_MESSAGE % (url, status_code)
raise Exception(message)
finally:
c.close()


def get_size(url) -> int:
Expand Down Expand Up @@ -122,6 +126,7 @@ def get_file(url, path: str):
message = GET_FAILED_MESSAGE % (url, status_code)
raise Exception(message)
finally:
c.close()
buf.close()


Expand Down