Skip to content
Open
Changes from all commits
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
17 changes: 10 additions & 7 deletions pulsar/client/transport/curl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
import io
import logging
import os.path
Expand Down Expand Up @@ -60,6 +61,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 +71,13 @@ 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)
with contextlib.closing(_new_curl_object_for_url(url)) as c:
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)


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


Expand Down