Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you print chunked output with curl?

Tags:

shell

curl

I can see chunked output as it arrives with:

curl http://asia.dabase.com:4000

However when I try loop and work with it like so:

curl -s http://asia.dabase.com:4000 | while read line; do echo $line; done

It doesn't print anything. :(

A previous answer suggests CURLOPT_WRITEFUNCTION, though I don't see how that's done from curl's manpage.

like image 917
hendry Avatar asked Nov 25 '22 06:11

hendry


1 Answers

I have since taken the site asia.dabase.com down, though I have found the solution using a tool I've never heard of until now called stdbuf.

stdbuf -oL curl -s http://asia.dabase.com:4000

This allows me to immediately start working with a chunked stream.

like image 140
hendry Avatar answered Nov 29 '22 06:11

hendry