How can I print the response headers to console and save the response content to a file?
I tried
http GET http://download.sysinternals.com/files/SysinternalsSuite.zip --output sis.zip
But this printed both the headers and content to the file, making it nonsense.
It is possible in an updated version, the --output
option will print the output into a file, and the --download
option will make sure that the headers are print to the console, and only the content to the output file.
Here is an example:
http GET "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles=Stack%20Overflow" --download --output bla.txt
This is what HTTPie does by default:
So, the output depends on where it is being printed to. You can overwrite the default context-sensitive behaviour with one of the output options. For example, the following saves the headers as well as the body to a file:
http --output sis.zip --print=hb download.sysinternals.com/files/SysinternalsSuite.zip
HTTPie currently doesn't allow outputing binary data to the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With