# Gavin Andresen # 2010-08-03 22:52:10 # https://bitcointalk.org/index.php?topic=689.msg7358#msg7358 @s{quotedtext} @s{quotedtext} Perl's LWP module definitely sets the Content-Length header. I would've been surprised if it didn't, since it is required by HTTP 1.0 and the HTTP 1.1 spec says clients 'SHOULD' set it. @p{par} After some struggle, I got the first @p{(link}JSON::RPC library@p{link)} at CPAN to work: @p{brk} Code: use JSON::RPC::Client; @p{brk} use Data::Dumper; @p{par} my $client = new JSON::RPC::Client; @p{par} $client-@s{gt}ua-@s{gt}credentials( @p{brk} 'localhost:8332', 'jsonrpc', 'my rpcusername' =@s{gt} 'my rpcpassword' # Replace with real user/pass @p{brk} ); @p{brk} my @foo = $client-@s{gt}ua-@s{gt}credentials('localhost:8332', 'jsonrpc'); @p{brk} print "@foo\n"; @p{par} my $uri = '@s{(link)}'; @p{brk} my $obj = { @p{brk} method =@s{gt} 'getinfo', @p{brk} params =@s{gt} [], @p{brk} }; @p{par} my $res = $client-@s{gt}call( $uri, $obj ); @p{par} if($res){ @p{brk} if ($res-@s{gt}is_error) { @p{brk} print "Error : ", $res-@s{gt}error_message; @p{brk} } @p{brk} else { @p{brk} print Dumper($res-@s{gt}result); @p{brk} } @p{brk} } @p{brk} else { @p{brk} print $client-@s{gt}status_line; @p{brk} } @p{brk} The struggle was setting the realm to 'jsonrpc' (it is fussy about that). I'll document that on the wiki. @p{par}