curl / Mailing Lists / curl-users / Single Mail

curl-users

Re: How to make libcurl show content while updating?

From: Nicholas Chambers <nchambers_at_lightspeedsystems.com>
Date: Thu, 2 Mar 2017 16:59:14 -0600

As an example, here is a program that shows https://www.google.com/
getting downloaded over a period of time:

[Nick@shell ~ {0}]$ ./download https://www.google.com/
Recieved 629 bytes of data.
0.025734 seconds have passed.
Recieved 1339 bytes of data.
0.025782 seconds have passed.
Recieved 1339 bytes of data.
0.025793 seconds have passed.
Recieved 1339 bytes of data.
0.025829 seconds have passed.
Recieved 1339 bytes of data.
0.025859 seconds have passed.
Recieved 1339 bytes of data.
0.025921 seconds have passed.
Recieved 1339 bytes of data.
0.025949 seconds have passed.
Recieved 1339 bytes of data.
0.025978 seconds have passed.
Recieved 1339 bytes of data.
0.026029 seconds have passed.
Recieved 1339 bytes of data.
0.026066 seconds have passed.
Recieved 1339 bytes of data.
0.026093 seconds have passed.
Recieved 1339 bytes of data.
0.026128 seconds have passed.
Recieved 1339 bytes of data.
0.026150 seconds have passed.
Recieved 1339 bytes of data.
0.026197 seconds have passed.
Recieved 1339 bytes of data.
0.026325 seconds have passed.
Recieved 1339 bytes of data.
0.026376 seconds have passed.
Recieved 1339 bytes of data.
0.026403 seconds have passed.
Recieved 1339 bytes of data.
0.026446 seconds have passed.
Recieved 1339 bytes of data.
0.026477 seconds have passed.
Recieved 1339 bytes of data.
0.026521 seconds have passed.
Recieved 1339 bytes of data.
0.026594 seconds have passed.
Recieved 1339 bytes of data.
0.026629 seconds have passed.
Recieved 1339 bytes of data.
0.026664 seconds have passed.
Recieved 1339 bytes of data.
0.026712 seconds have passed.
Recieved 1339 bytes of data.
0.026740 seconds have passed.
Recieved 3 bytes of data.
0.026769 seconds have passed.
Recieved 1334 bytes of data.
0.026808 seconds have passed.
Recieved 1005 bytes of data.
0.026821 seconds have passed.
Recieved 1333 bytes of data.
0.026873 seconds have passed.
Recieved 1339 bytes of data.
0.026925 seconds have passed.
Recieved 1339 bytes of data.
0.026960 seconds have passed.
Recieved 1339 bytes of data.
0.027017 seconds have passed.
Recieved 1339 bytes of data.
0.027052 seconds have passed.
Recieved 1339 bytes of data.
0.027104 seconds have passed.
Recieved 1339 bytes of data.
0.027159 seconds have passed.
Recieved 932 bytes of data.
0.027191 seconds have passed.
[Nick_at_shell ~ {0}]$

(Not necessarily proper CURL program is attached as download.c)

On 3/2/17 4:29 PM, Nicholas Chambers wrote:
>
> What do you mean "after it finish"? As libcurl receives data, it makes
> it available to you (the programmer) through a callback function. It
> doesn't wait until it has the webpage or file completely downloaded.
>
>
> On 3/2/17 4:07 PM, Rodrigo Zanatta Silva wrote:
>> Lol, but you don't understand. The libcurl will only get the page
>> after it finish. So, it will take 110 seconds and than show all
>> eleven lines.
>>
>> But, can I get PARTIAL result? Like every 5 seconds read the *stdout*
>> of the server, like:
>>
>> *TIME 0: Call the URL*
>> *
>> *
>> *TIME 5: Read*
>> line 0
>>
>> *TIME 10: Read*
>> line 0
>> line 1
>>
>> *TIME 15: Read*
>> line 0
>> line 1
>>
>> *TIME 20: Read*
>> line 0
>> line 1
>> line 2
>> *TIME 25: Read*
>> ...
>> *TIME 110: Finish*
>> (only now curl print everything)
>>
>> Is this possible? Or do I need to use another strategy? Like write
>> this in file and read it.
>>
>> 2017-03-02 18:16 GMT-03:00 Daniel Stenberg <daniel_at_haxx.se
>> <mailto:daniel_at_haxx.se>>:
>>
>> On Wed, 1 Mar 2017, Rodrigo Zanatta Silva wrote:
>>
>> How can I make libcurl show this page while it is building,
>> like in browser?
>>
>>
>> libcurl delivers the data to the application as it arrives so it
>> is up to the application to deal with that. Like a browser or
>> otherwise.
>>
>> --
>>
>> / daniel.haxx.se <http://daniel.haxx.se>
>> -----------------------------------------------------------
>> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
>> <https://cool.haxx.se/list/listinfo/curl-users>
>> Etiquette: https://curl.haxx.se/mail/etiquette.html
>> <https://curl.haxx.se/mail/etiquette.html>
>>
>>
>>
>>
>> -----------------------------------------------------------
>> Unsubscribe:https://cool.haxx.se/list/listinfo/curl-users
>> Etiquette:https://curl.haxx.se/mail/etiquette.html
>
> --
> Nicholas Chambers
> Technical Support Specialist
> nchambers_at_lightspeedsystems.com
> 1.800.444.9267
> www.lightspeedsystems.com
>
>
> -----------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-- 
Nicholas Chambers
Technical Support Specialist
nchambers_at_lightspeedsystems.com
1.800.444.9267
www.lightspeedsystems.com


-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html

Received on 2017-03-02