### ----------------------------------------------------
### -- LibCurl
### -- Licenses: NASA-1.3
### -- Authors: Curt Tilmes <Curt.Tilmes@nasa.gov>
### -- File: eg/multi.raku
### ----------------------------------------------------
#!/usr/bin/env raku
use LibCurl::Easy;
use LibCurl::Multi;

my $curl1 = LibCurl::Easy.new(:followlocation, URL => 'http://example.com');
my $curl2 = LibCurl::Easy.new(:followlocation, URL => 'http://example.com');

sub callback(LibCurl::Easy $easy, Exception $e)
{
    say $easy.effective-url, " finished";
    say $e ?? "error: $e.message()" !! $easy.statusline;
}

my $multi = LibCurl::Multi.new(callback => &callback);

$multi.add-handle($curl1, $curl2);

$multi.perform;

say "done";


