Skip to content

Commit 9513146

Browse files
committed
Merge pull request #468 from CPAN-API/encoded_river
Accept gzipped river data
2 parents 47349eb + 4b168df commit 9513146

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: lib/MetaCPAN/Script/River.pm

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ has river_url => (
1515
isa => Uri,
1616
coerce => 1,
1717
required => 1,
18-
default => 'https://neilb.org/FIXME',
18+
default => 'http://neilb.org/river-of-cpan.json.gz',
1919
);
2020

2121
has _ua => (
@@ -53,7 +53,14 @@ sub retrieve_river_summaries {
5353

5454
$self->handle_error( $resp->status_line ) unless $resp->is_success;
5555

56-
return decode_json $resp->content;
56+
# cleanup headers if .json.gz is served as gzip type
57+
# rather than json encoded with gzip
58+
if ( $resp->header('Content-Type') eq 'application/x-gzip' ) {
59+
$resp->header( 'Content-Type' => 'application/json' );
60+
$resp->header( 'Content-Encoding' => 'gzip' );
61+
}
62+
63+
return decode_json $resp->decoded_content;
5764
}
5865

5966
__PACKAGE__->meta->make_immutable;

0 commit comments

Comments
 (0)