diff options
author | Struan Donald <struan@exo.org.uk> | 2012-03-28 16:51:09 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-03-28 16:51:09 +0100 |
commit | 46592020068908e41ae1d20c04a9080bb6a4a0da (patch) | |
tree | bbd1a97e4a0e6d4aa1e6a6d9daa61ae30ad51af4 /perllib/Open311.pm | |
parent | 889db209c6343ec7e3985209f6d6a8f98278d665 (diff) |
fetch content properly so we can set error messages and so on
Diffstat (limited to 'perllib/Open311.pm')
-rw-r--r-- | perllib/Open311.pm | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/perllib/Open311.pm b/perllib/Open311.pm index 368982a2a..2d50ed91f 100644 --- a/perllib/Open311.pm +++ b/perllib/Open311.pm @@ -232,12 +232,20 @@ sub _get { $content = $self->test_get_returns->{ $path }; $self->test_uri_used( $uri->as_string ); } else { - $content = get( $uri->as_string ); - if ( $content == undef ) { - $self->success(0); - $self->error('Failed to fetch'); - } else { + my $ua = LWP::UserAgent->new; + + my $req = HTTP::Request->new( + GET => $uri->as_string + ); + + my $res = $ua->request( $req ); + + if ( $res->is_success ) { + $content = $res->decoded_content; $self->success(1); + } else { + $self->success(0); + $self->error( $res->status_line ); } } |