You've already forked httpie-cli
mirror of
https://github.com/httpie/cli.git
synced 2025-08-10 22:42:05 +02:00
Changed the way the output filename is generated
When ``--download`` without ``--output`` results in a redirect, now only the initial URL is considered, not the final one.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
import pytest
|
||||
@@ -22,6 +23,7 @@ class Response(object):
|
||||
|
||||
|
||||
class TestDownloadUtils:
|
||||
|
||||
def test_Content_Range_parsing(self):
|
||||
parse = parse_content_range
|
||||
|
||||
@@ -166,3 +168,15 @@ class TestDownloads:
|
||||
downloader.finish()
|
||||
assert downloader.interrupted
|
||||
downloader._progress_reporter.join()
|
||||
|
||||
def test_download_with_redirect_original_url_used_for_filename(self, httpbin):
|
||||
# Redirect from `/redirect/1` to `/get`.
|
||||
expected_filename = '1.json'
|
||||
orig_cwd = os.getcwd()
|
||||
os.chdir(tempfile.mkdtemp(prefix='httpie_download_test_'))
|
||||
try:
|
||||
assert os.listdir('.') == []
|
||||
http('--download', httpbin.url + '/redirect/1')
|
||||
assert os.listdir('.') == [expected_filename]
|
||||
finally:
|
||||
os.chdir(orig_cwd)
|
||||
|
Reference in New Issue
Block a user