statu_line

This is my simple script:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D
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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=
=3D=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?
thesaltydog [ Mo, 16 Mai 2005 15:39 ] [ ID #795665 ]

Re: statu_line

The Saltydog <thesaltydog [at] gmail.com> 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
gisle [ Mo, 16 Mai 2005 15:49 ] [ ID #795666 ]

Re: statu_line

Your are perfectly right.. Sorry!

On 16 May 2005 06:49:26 -0700, Gisle Aas <gisle [at] activestate.com> wrote:
> The Saltydog <thesaltydog [at] gmail.com> writes:
>
> > This is my simple script:
> >
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D
> > 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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=
=3D=3D=3D=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?
>
> I bet your script has quotes around the "$response->status_line"
> expression. The program above does not produce the output you claim.
>
> Regards,
> Gisle
>
thesaltydog [ Mo, 16 Mai 2005 15:50 ] [ ID #795667 ]
Perl » perl.libwww » statu_line

Vorheriges Thema: HTML::TreeBuilder eating my entities using perl 5.8.x
Nächstes Thema: Transparenz ist das Mindeste