statu_line

statu_line

am 16.05.2005 15:39:38 von thesaltydog

This is my simple script:

==================== ==
require LWP::UserAgent;
=20
my $ua =3D LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
=20
my $response =3D $ua->get('http://search.cpan.org/');
=20
if ($response->is_success) {
print $response->content; # or whatever
}
else {
die $response->status_line;
}
==================== =====3D=
==

If I type a wrong url instead of www.cpan.org, the script doesn't
return a "status_line"... This is the program output:

HTTP::Response=3DHASH(0x845d084)->status_line

Where am I wrong?

Re: statu_line

am 16.05.2005 15:49:26 von gisle

The Saltydog writes:

> This is my simple script:
>
> ======================
> require LWP::UserAgent;
>
> my $ua = LWP::UserAgent->new;
> $ua->timeout(10);
> $ua->env_proxy;
>
> my $response = $ua->get('http://search.cpan.org/');
>
> if ($response->is_success) {
> print $response->content; # or whatever
> }
> else {
> die $response->status_line;
> }
> ===========================
>
> If I type a wrong url instead of www.cpan.org, the script doesn't
> return a "status_line"... This is the program output:
>
> HTTP::Response=HASH(0x845d084)->status_line
>
> Where am I wrong?

I bet your script has quotes around the "$response->status_line"
expression. The program above does not produce the output you claim.

Regards,
Gisle

Re: statu_line

am 16.05.2005 15:50:43 von thesaltydog

Your are perfectly right.. Sorry!

On 16 May 2005 06:49:26 -0700, Gisle Aas wrote:
> The Saltydog writes:
>=20
> > This is my simple script:
> >
> > ==================== ==
> > require LWP::UserAgent;
> >
> > my $ua =3D LWP::UserAgent->new;
> > $ua->timeout(10);
> > $ua->env_proxy;
> >
> > my $response =3D $ua->get('http://search.cpan.org/');
> >
> > if ($response->is_success) {
> > print $response->content; # or whatever
> > }
> > else {
> > die $response->status_line;
> > }
> > ==================== ===3D=
====
> >
> > If I type a wrong url instead of www.cpan.org, the script doesn't
> > return a "status_line"... This is the program output:
> >
> > HTTP::Response=3DHASH(0x845d084)->status_line
> >
> > Where am I wrong?
>=20
> I bet your script has quotes around the "$response->status_line"
> expression. The program above does not produce the output you claim.
>=20
> Regards,
> Gisle
>