Streamed responses
Responses are downloaded and printed in chunks which allows for streamingand large file downloads without using too much memory. However, whencolors and formatting is applied, the whole response is buffered and onlythen processed at once.
Disabling buffering
You can use the —stream, -S
flag to make two things happen:
tail -f
for URLs.- Streaming becomes enabled even when the output is prettified: It will beapplied to each line of the response and flushed immediately. This makesit possible to have a nice output for long-lived requests, such as oneto the Twitter streaming API.Examples use cases
Prettified streamed response:
- $ http --stream -f -a YOUR-TWITTER-NAME https://stream.twitter.com/1/statuses/filter.json track='Justin Bieber'
Streamed output by small chunks alá tail -f
:
- # Send each new tweet (JSON object) mentioning "Apple" to another
- # server as soon as it arrives from the Twitter streaming API:
- $ http --stream -f -a YOUR-TWITTER-NAME https://stream.twitter.com/1/statuses/filter.json track=Apple \
- | while read tweet; do echo "$tweet" | http POST example.org/tweets ; done