Subject: | WWW::Curl::Easy Segfaults when using setopt(CURLOPT_HTTPHEADER, $headers) for string value $headers |
Date: | Wed, 9 May 2018 05:26:28 +0000 |
To: | bug-WWW-Curl [...] rt.cpan.org |
From: | Jefferson Carpenter <jefferson [...] aoeu2code.com> |
uname -a
Linux thekincasino 4.4.0-119-generic #143-Ubuntu SMP Mon Apr 2 16:08:24
UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
perl -v
5.22.1
perl -e 'use WWW::Curl::Easy; print $WWW::Curl::VERSION;'
4.17
The following code segfaults:
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Curl::Easy;
my $url = 'http://localhost:8545';
my $headers = "Content-Type: application/json";
my $data =
"{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":67}";
my $response_body;
my $curl = WWW::Curl::Easy->new;
$curl->setopt(CURLOPT_WRITEDATA, \$response_body);
$curl->setopt(CURLOPT_URL, $url);
$curl->setopt(CURLOPT_POST, 1);
$curl->setopt(CURLOPT_HTTPHEADER, $headers);
$curl->setopt(CURLOPT_POSTFIELDS, $data);
my $statuscode = $curl->perform;