Created
January 30, 2018 21:49
-
-
Save bazzaar/040af6a440c86201c3921a2740a82c69 to your computer and use it in GitHub Desktop.
IO spurt Cro http request response to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import the client class. | |
use Cro::HTTP::Client; | |
my $client = Cro::HTTP::Client.new( | |
headers => [ | |
User-agent => 'Cro' | |
]); | |
# Make the request | |
#### | |
my $url = 'https://www.perl6.org/'; | |
my $resp = await $client.get($url); | |
my $body = await $resp.body; | |
"perl6_header.txt".IO.spurt: $resp; | |
"perl6_body.txt".IO.spurt: $body; | |
# Result | |
#### | |
# "perl6_header.txt" file made, but has 0 bytes | |
# "perl6_body.txt" file not made, instead : | |
# Cannot resolve caller spurt(IO::Handle: Cro::HTTP::Response, :close); none of these signatures match: | |
# (IO::Handle:D $: Blob $data, :$close, *%_) | |
# (IO::Handle:D $: Cool $data, :$close, *%_) | |
# in block <unit> at perl6_cro_simple_http_request.p6 line 29 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment