diff options
author | franck cuny <franck.cuny@gmail.com> | 2012-01-02 15:29:30 -0800 |
---|---|---|
committer | franck cuny <franck.cuny@gmail.com> | 2012-01-02 15:29:30 -0800 |
commit | f61a039c9d376baff3c54577d5c65abd6a857e85 (patch) | |
tree | 00176a57db63efa025e5437b34f2dd69632d547b /lib/Net/HTTP | |
parent | use eq and ne instead of a regex (diff) | |
parent | use eq and ne instead of a regex (diff) | |
download | net-http-spore-f61a039c9d376baff3c54577d5c65abd6a857e85.tar.gz |
Merge branch 'bricas'
* bricas: use eq and ne instead of a regex pod fix confess when we are unable to fetch a spec via LWP remove unused var; simplify conditions fix warnings in test
Diffstat (limited to 'lib/Net/HTTP')
-rw-r--r-- | lib/Net/HTTP/Spore.pm | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Net/HTTP/Spore.pm b/lib/Net/HTTP/Spore.pm index 87454c9..5c4f0c7 100644 --- a/lib/Net/HTTP/Spore.pm +++ b/lib/Net/HTTP/Spore.pm @@ -88,13 +88,8 @@ sub _attach_spec_to_class { }; try { - my $base_url; - if ( $spec->{base_url} && !$opts->{base_url} ) { - $opts->{base_url} = $spec->{base_url}; - } - elsif ( !$opts->{base_url} ) { - die "base_url is missing!"; - } + $opts->{base_url} ||= $spec->{base_url}; + die "base_url is missing!" if !$opts->{base_url}; if ( $spec->{formats} ) { $opts->{formats} = $spec->{formats}; @@ -126,6 +121,10 @@ sub _read_spec { my $req = HTTP::Request->new( GET => $spec_file ); my $ua = LWP::UserAgent->new(); my $res = $ua->request($req); + unless( $res->is_success ) { + my $status = $res->status_line; + Carp::confess("Unabled to fetch $spec_file ($status)"); + } $content = $res->content; } else { @@ -215,7 +214,7 @@ L<Net::HTTP::Spore> provides a way to trace what's going on when doing a request =head3 Enabling Trace -You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E-<GT> 1> when calling B<new_from_spec>. +You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E<gt> 1> when calling B<new_from_spec>. =head3 Trace Output |