我想在脚本中使用 Github API,我想把它作为一种体验来更好地使用 Perl6。但是,我什至无法获得一个简单的概念证明来工作。
通过一些测试,我意识到 Github要求您提供有效的用户代理,因此我转向HTTP::UserAgent。无论我尝试什么,我都会收到以下错误:
Internal Error: 'server returned no data'
in block at /Applications/Rakudo/share/perl6/site/sources/FD28A8E22DFE16B70B757D9981C7B6C25543060C (HTTP::UserAgent) line 259
in any at /Applications/Rakudo/share/perl6/site/precomp/F91BAB44DF15C5C298C627DD5E0F9D819ED79939.1517344679.60204/FD/FD28A8E22DFE16B70B757D9981C7B6C25543060C line 1
in method new at /Applications/Rakudo/share/perl6/site/sources/DDDD4497B34FC81BC1F5FF467999BC4DA2FA1CEB (HTTP::Response) line 25
in method get-response at /Applications/Rakudo/share/perl6/site/sources/FD28A8E22DFE16B70B757D9981C7B6C25543060C (HTTP::UserAgent) line 291
in method request at /Applications/Rakudo/share/perl6/site/sources/FD28A8E22DFE16B70B757D9981C7B6C25543060C (HTTP::UserAgent) line 159
in method get at /Applications/Rakudo/share/perl6/site/sources/FD28A8E22DFE16B70B757D9981C7B6C25543060C (HTTP::UserAgent) line 102
in method get at /Applications/Rakudo/share/perl6/site/sources/FD28A8E22DFE16B70B757D9981C7B6C25543060C (HTTP::UserAgent) line 105
in block <unit> at reporter.pl6 line 12
回购中甚至有一个似乎对我不起作用的例子。
#!/usr/bin/env perl6
use v6;
use HTTP::UserAgent;
my $ua = HTTP::UserAgent.new;
$ua.timeout = 1;
my $response = $ua.get('https://github.com');
if $response.is-success {
say $response.content;
} else {
die $response.status-line;
}
关于如何通过 Perl 6 连接到 Github 的任何提示?我真的很喜欢这种语言的许多方面,但这种事情令人沮丧。
编辑:我继续#perl6 irc,没有人能够在其他操作系统上重现这一点。我让它在 Debian 上工作。问题似乎出在 OS X