From 937cf96344345c09a2a803ed19110951ccc6bb45 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Thu, 21 Jul 2011 03:57:52 +0200 Subject: [PATCH] Exporter may respond with a structure now --- lib/WWW/GoodData.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/WWW/GoodData.pm b/lib/WWW/GoodData.pm index bcd15f4..1693ec6 100644 --- a/lib/WWW/GoodData.pm +++ b/lib/WWW/GoodData.pm @@ -369,12 +369,18 @@ sub export_report report => $self->compute_report ($report) }} ); + # This is for new release, where location is finally set correctly; + $result = $result->{uri} if ref $result eq 'HASH'; + # Trigger the export my $exported = $self->poll ( sub { $self->{agent}->get ($result) }, - sub { shift->{raw} ne 'null' } + sub { $_[0] and exists $_[0]->{raw} and $_[0]->{raw} ne 'null' } ) or die 'Timed out waiting for report to export'; + # Follow the link + $exported = $self->{agent}->get ($exported->{uri}) if exists $exported->{uri}; + # Gotten the correctly coded result? return $exported->{raw} if $exported->{type} eq { png => 'image/png',