Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Shorten-Bitly CPAN distribution.

Report information
The Basics
Id: 47242
Status: resolved
Priority: 0/
Queue: WWW-Shorten-Bitly

People
Owner: Nobody in particular
Requestors: pedwards [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.106
Fixed in: (no value)



Subject: Does not fail gracefully when bit.ly not accessible
Use WWW::Shorten::Bitly::makeashorterlink() via an HTTP proxy and if the proxy cannot reach bit.ly then you get an error. E.g. write a simple program bitly_test.pl that calls makeashorterlink with your user and apikey, then run it like $ http_proxy=http://NOTAREALDOMAIN perl bitly_test.pl And you get: garbage after JSON object, at character offset 4 ["Can't connect to NOT..."] at /home/edwarp11/perl5/lib/perl5/JSON/Any.pm line 491. In makeashorterlink() after the call $bitly->{response} = $ua->get($biturl); it needs to catch an HTTP GET failure. Patch supplied with fix so it gives a meaningful error: failed to get bit.ly link: 500 Can't connect to NOTAREALDOMAIN:80 (Bad hostname 'NOTAREALDOMAIN') at /home/edwarp11/perl5/lib/perl5/WWW/Shorten/Bitly.pm line 138.
Subject: patch.txt
--- /home/edwarp11/perl5/lib/perl5/WWW/Shorten/Bitly.pm 2009-06-22 15:34:19.000000000 +0100 +++ /tmp/Bitly.pm 2009-06-22 15:34:07.000000000 +0100 @@ -135,6 +135,8 @@ $bitly->{xml} = new XML::Simple(SuppressEmpty => 1); my $biturl = "http://api.bit.ly/shorten?history=1&version=2.0.1&longUrl=" . $url . "&login=" . $user . "&apiKey=" . $apikey; $bitly->{response} = $ua->get($biturl); + $bitly->{response}->is_success + || die 'failed to get bit.ly link: '.$bitly->{response}->status_line; $bitly->{bitlyurl} = $bitly->{json}->jsonToObj($bitly->{response}->{_content})->{results}->{$url}->{shortUrl}; return unless $bitly->{response}->is_success; return $bitly->{bitlyurl};
On Mon Jun 22 10:37:17 2009, PEDWARDS wrote: Show quoted text
> Use WWW::Shorten::Bitly::makeashorterlink() via an HTTP proxy and if > the proxy cannot reach bit.ly then you get an error. > > E.g. write a simple program bitly_test.pl that calls makeashorterlink > with your user and apikey, then run it like > > $ http_proxy=http://NOTAREALDOMAIN perl bitly_test.pl > > And you get: > > garbage after JSON object, at character offset 4 ["Can't connect to > NOT..."] at /home/edwarp11/perl5/lib/perl5/JSON/Any.pm line 491. > > In makeashorterlink() after the call > > $bitly->{response} = $ua->get($biturl); > > it needs to catch an HTTP GET failure. > > Patch supplied with fix so it gives a meaningful error: > > failed to get bit.ly link: 500 Can't connect to NOTAREALDOMAIN:80 (Bad > hostname 'NOTAREALDOMAIN') at > /home/edwarp11/perl5/lib/perl5/WWW/Shorten/Bitly.pm line 138. >
Peter, Your patch is integrated along with a few others. New version is in testing right now. I will release once testing is complete. Thanks for your contribution.