Hi,

I am using the following code to access a site as described in your example:
(replacing <xxxxx> with the values)

#!/usr/bin/perl -w
use strict;
$|++;

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;
$ua->proxy(['http', 'ftp', 'https'], 'http://<MyUsername>:<MyPassword>@<
MyProxy>:1080');

my $req = HTTP::Request->new(GET => 'https://www.helsinki.fi/');
my $res = $ua->request($req);
if ($res->is_success) {
print $res->as_string;
}
else {
print "Failed: ", $res->status_line, "\n";
}

output is :
Failed: 400 Bad Request

please guide,
TIA,
Prateek


On 10/21/05, Prateek <[EMAIL PROTECTED]> wrote:
> Thanks ! This worked for HTTP ! I appreciate your quick help.
> how to make it work for HTTPS ?
> The same code does not work for https://.......
>
> My program has to access http urls and http urls , both..
>
> TIA,
> Prateek
>
>
> On 21 Oct 2005 07:04:58 -0700, Gisle Aas <[EMAIL PROTECTED]> wrote:
> > Prateek <[EMAIL PROTECTED]> writes:
> >
> > > $ua->proxy()
> > > is not accepting username and password as parameters.
> >
> > Did you read the section pointed to the the URL I provided? It says:
> >
> > | Some proxies also require that you send it a username/password in
> > | order to let requests through. You should be able to add the
> > | required header, with something like this:
> > |
> > | use LWP::UserAgent;
> > |
> > | $ua = LWP::UserAgent->new;
> > | $ua->proxy(['http', 'ftp'] => '
http://username:[EMAIL PROTECTED]');
> > |
> > | $req = HTTP::Request->new('GET',"http://www.perl.com";);
> > |
> > | $res = $ua->request($req);
> > | print $res->decoded_content if $res->is_success;
> > |
> > | Replace proxy.myorg.com <http://proxy.myorg.com>, username and
password with something
> > | suitable for your site.
> >
> >
> > > On 21 Oct 2005 05:29:42 -0700, Gisle Aas <[EMAIL PROTECTED]>
wrote:
> > > > Prateek <[EMAIL PROTECTED]> writes:
> > > >
> > > > > It seems that LWP::UserAgent does not support proxy with
authentication.
> > > >
> > > > Proxies with authentication is supported. See:
> > > >
> > > > http://search.cpan.org/~gaas/libwww-perl-5.803/lwpcook.pod#PROXIES
> >
>
>
> --
> -----------------------------------------------------------------
> Prateek Srivastava
> 2003 Batch CSE
> M M M Engineering College, Gorakhpur.
> INDIA
>


--
-----------------------------------------------------------------
Prateek Srivastava
2003 Batch CSE
M M M Engineering College, Gorakhpur.
INDIA

Reply via email to