Subject: | Fails badly if it can't get metadata (i.e., if the stream is bad) |
It's been changed from "croak"ing to setting $@ with the error message and indicating that the string is disconnected.
Also, there were a lot of undefined-concatenation errors around line 141; these have been fixed by providing a default for the useragent if it's undefined at about that point.
diff -Nru a/lib/Netx/WebRadio/Station/Shoutcast.pm b/lib/Netx/WebRadio/Station/Shoutcast.pm
--- a/lib/Netx/WebRadio/Station/Shoutcast.pm 2005-05-18 10:37:56.000000000 -0500
+++ b/lib/Netx/WebRadio/Station/Shoutcast.pm 2005-05-18 10:49:25.000000000 -0500
@@ -139,12 +139,16 @@
if ( $self->get_state eq 'SENDHEADER' ) {
my $path = $self->path || '/';
my $header = $self->{_header}
- || "GET $path HTTP/1.0\r\n" . "Host:"
- . $self->host() . "\r\n"
- . "Accept:*/*\r\n"
- . "User-Agent:"
- . $self->useragent() . "\r\n"
- . "Icy-Metadata:1\r\n\r\n";
+ || "GET $path HTTP/1.0\r\n";
+ $header .= "Host:";
+ $header .= $self->host() . "\r\n";
+ $header .= "Accept:*/*\r\n";
+ $header .= "User-Agent:";
+ if( !defined( $self->useragent() ) ) {
+ $self->useragent( "Netx::WebRadio::Station::Shoutcast" );
+ }
+ $header .= $self->useragent() . "\r\n";
+ $header .= "Icy-Metadata:1\r\n\r\n";
my $bytes = $self->icySyswrite( $socket, $header );
unless ($bytes) {
return 1 if $! == EAGAIN;
@@ -178,7 +182,8 @@
$self->{_metaLength} = $1;
}
else {
- croak "no length-information in MetaData\n";
+ $@="no length-information in MetaData\n";
+ return $self->disconnected();
}
for my $line ( split /\r\n/, $header ) {
if ( $line =~ /^icy/ ) {