Skip to content

Commit f87f376

Browse files
committed
Switch to Cro::HTTP::Client
Improve error diagnostics It's faster Actually handle 429 errors
1 parent 2b20570 commit f87f376

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

META6.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
],
99
"auth": "perl6",
1010
"test-depends": [
11+
"Cro::HTTP::Client",
1112
"HTTP::UserAgent",
12-
"HTTP::Tiny",
1313
"File::Temp",
1414
"Test::META",
1515
"Doc::TypeGraph"

xt/rakudoc-l.rakutest

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use lib $*PROGRAM.parent(2).child('lib');
1111

1212
use Test-Files;
1313
use Pod::Convenience;
14+
use Cro::HTTP::Client;
1415

1516
my @files = Test-Files.pods;
1617

@@ -20,6 +21,7 @@ if @files {
2021
plan :skip-all<No rakudoc files specified>
2122
}
2223

24+
my $ua = Cro::HTTP::Client.new;
2325

2426
sub is-valid-display($content) {
2527
if $content.starts-with('#') {
@@ -92,9 +94,24 @@ sub is-valid-link($links) {
9294
} else {
9395
my @valid-protocols = <http https>;
9496
if $link.starts-with(any(@valid-protocols) ~ '://') {
95-
use HTTP::Tiny;
96-
my $response = HTTP::Tiny.new.get: $link;
97-
ok($response<success>, "HTTP $response<status> $link");
97+
my $response = await $ua.get: $link;
98+
CATCH {
99+
when X::Cro::HTTP::Error {
100+
if .response.status == 429 {
101+
my $retry-after = .response.header('retry-after');
102+
sleep $retry-after;
103+
redo;
104+
} else {
105+
flunk "HTTP {.response.status} $link";
106+
}
107+
}
108+
default {
109+
diag .^name;
110+
flunk "HTTP Unknown error: $link";
111+
}
112+
next;
113+
}
114+
pass "HTTP {$response.status} $link";
98115
next;
99116
}
100117

0 commit comments

Comments
 (0)