#!/usr/bin/perl use strict; use warnings; use 5.010; use utf8; use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new; $ua->agent("MyApp/0.1 "); $ua->default_header('Accept-Encoding' => 'gzip'); # Create a request my $req = HTTP::Request->new(GET => 'https://labs.gwendragon.de/test/data.xml'); # Pass request to the user agent and get a response back my $res = $ua->request($req); my ($content, $output); # Check the outcome of the response if ($res->is_success) { $content = $res->content; say $req->as_string; say $res->as_string; say '------------------------------'; } else { say $res->status_line; } say ""; say "===== Gunzpped ==============="; use IO::Uncompress::Gunzip qw(gunzip $GunzipError); my $status = gunzip(\$content => \$output) or die "gunzip failed: $GunzipError\n"; say $output; open my $FH, '>', 'get.data'; binmode $FH; say $FH $output;