mirror of
https://github.com/httpie/cli.git
synced 2026-06-20 11:32:56 +02:00
Replace --show-redirects with --all and add --print-others, -P
With --all, any intermediary requests/responses are shown (such as redirects or the initial unauthorized Digest auth request). The --print-others, -P option works like --print, -p, but only applies to intermediary requests/responses. The default behaviour is to inherit the value of -p.
This commit is contained in:
1 parent
a6ebc44a48
commit
6e1dbadff9
7 files changed
+137
-52
No files matched your search
+10
-5
@@ -96,11 +96,11 @@ def program(args, env, log_error):
|
||||
)
|
||||
downloader.pre_request(args.headers)
|
||||
|
||||
last_response = get_response(args, config_dir=env.config.directory)
|
||||
if args.show_redirects:
|
||||
responses = last_response.history + [last_response]
|
||||
final_response = get_response(args, config_dir=env.config.directory)
|
||||
if args.all:
|
||||
responses = final_response.history + [final_response]
|
||||
else:
|
||||
responses = [last_response]
|
||||
responses = [final_response]
|
||||
|
||||
for response in responses:
|
||||
|
||||
@@ -121,6 +121,11 @@ def program(args, env, log_error):
|
||||
env=env,
|
||||
request=response.request,
|
||||
response=response,
|
||||
output_options=(
|
||||
args.output_options
|
||||
if response is final_response
|
||||
else args.output_options_others
|
||||
)
|
||||
),
|
||||
# NOTE: `env.stdout` will in fact be `stderr` with `--download`
|
||||
'outfile': env.stdout,
|
||||
@@ -140,7 +145,7 @@ def program(args, env, log_error):
|
||||
|
||||
if downloader and exit_status == ExitStatus.OK:
|
||||
# Last response body download.
|
||||
download_stream, download_to = downloader.start(last_response)
|
||||
download_stream, download_to = downloader.start(final_response)
|
||||
write_stream(
|
||||
stream=download_stream,
|
||||
outfile=download_to,
|
||||
|
||||
Reference in new issue
Block a user