cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: How to use keep-alive in a Bash co-process?

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 24 Nov 2014 23:18:17 +0100

On Mon, Nov 24, 2014 at 05:17:26PM +0100, Sascha Ziemann wrote:
> I need to download several files and I would like to use keep-alive, because it
> is an TSL connection and the connection establishment is quite slow. But I am
> not able to specify all URLs in the command line, because they depend on each
> other. The second URL gets calculated by the content of the first URL and so
> on. I would like to use curl in a co-process. I tried to open a pipe to curl
> -sSLK- in order to send url="" and output="" commands to curl. But curl does
> not start with the download. Instead it waits until the pipe gets closed. This
> prevents the calculation of the second URL, because the body of the first is
> never downloaded.
>
> How can I tell curl to start immediately with the first download as soon as a
> url/output pair has been read from stdin?

This isn't possible. Many options are global, so the order of appearance on the
command-line doesn't matter so curl must wait until the entire command-line
(read: config file) is read and all options parsed before it can start the
first transfer. For an application like this you'll need to use one of the
libcurl bindings and rewrite your script. Chances are, there's a binding
available in your favourite scripting language [1] so this probably isn't as
big a deal as it may seem. The --libcurl option can also be used to obtain a
list of the various options your curl command-line invocation currently uses.

[1] http://curl.haxx.se/libcurl/

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-11-24