Skip to content

Commit

Permalink
206 is the valid response code for a range request.
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed May 7, 2015
1 parent 4ed7c5d commit 86f95ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pulsar/client/transport/curl.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,20 @@ def get_file(url, path):
if path and os.path.exists(path):
buf = _open_output(path, 'ab')
size = os.path.getsize(path)
success_codes = (200, 206)
else:
buf = _open_output(path)
size = 0
success_codes = (200,)
try:
c = _new_curl_object_for_url(url)
c.setopt(c.WRITEFUNCTION, buf.write)
if size > 0:
log.info('transfer of %s will resume at %s bytes', url, size)
c.setopt(c.RESUME_FROM, size)
c.perform()
status_code = c.getinfo(HTTP_CODE)
if int(status_code) != 200:
status_code = int(c.getinfo(HTTP_CODE))
if status_code not in success_codes:
message = GET_FAILED_MESSAGE % (url, status_code)
raise Exception(message)
finally:
Expand Down

0 comments on commit 86f95ce

Please sign in to comment.