From d32acfe2fae3c31c847fbd02772cbf6ec3767a22 Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Fri, 12 Apr 2013 11:56:05 -0300 Subject: [PATCH] Only use Range when already have a partial download. --- httpie/downloads.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/httpie/downloads.py b/httpie/downloads.py index 9acd2eff..62d80c93 100644 --- a/httpie/downloads.py +++ b/httpie/downloads.py @@ -170,12 +170,8 @@ class Download(object): # Disable content encoding so that we can resume, etc. request_headers['Accept-Encoding'] = None if self._resume: - try: - bytes_have = os.path.getsize(self._output_file.name) - except OSError as e: - if e.errno != errno.ENOENT: - raise - else: + bytes_have = os.path.getsize(self._output_file.name) + if bytes_have: # Set ``Range`` header to resume the download # TODO: Use "If-Range: mtime" to make sure it's fresh? request_headers['Range'] = 'bytes=%d-' % bytes_have