1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

Added support for output redirection with --download (#104).

This commit is contained in:
Jakub Roztocil
2013-04-12 11:04:14 -03:00
parent 464b7a36da
commit 341272db1e
2 changed files with 16 additions and 2 deletions

View File

@@ -149,6 +149,7 @@ class Download(object):
:type progress_file: file
"""
assert output_file, output_file
self._output_file = output_file
self._resume = resume
self._resumed_from = 0
@@ -208,8 +209,11 @@ class Download(object):
else:
self._resumed_from = 0
self._output_file.seek(0)
self._output_file.truncate()
try:
self._output_file.seek(0)
self._output_file.truncate()
except IOError:
pass # stdout
else:
# TODO: Should the filename be taken from response.history[0].url?
# Output file not specified. Pick a name that doesn't exist yet.