Newbie URI::URL question 
Author Message
 Newbie URI::URL question

I'm trying to understand  the URI::URL module  with this simple program. Seems
I do not understand the user and password constructs, which I think I need to
to be able to write an LWP program that will get past my company's firewall.
Can someone tell me what I am doing wrong?

The program:

#!/apps/SunOS/5/bin/perl -w
#
use URI::URL;
#
$url = new URI::URL(

#
#
$myurl =  $url->as_string();
print "The whole enchilada: $myurl\n";
#
$myscheme = $url->scheme();
print "Scheme: $myscheme\n";
#
$mynetloc = $url->netloc();
print "Netloc: $mynetloc\n";
#
$myuser = $url->user;
print "User: $myuser\n";
#
$mypass = $url->password();
print "Password: $mypass\n";
#
$myhost = $url->host();
print "Host: $myhost\n";
#
$myport = $url->port();
print "Port: $myport\n";
#
$mypath = $url->path();
print "Path: $mypath\n";


The output is

The whole enchilada:

Scheme: http

Use of uninitialized value at ./testURL.pl line 18.
User:
Use of uninitialized value at ./testURL.pl line 21.
Password:
Host: www.foobar.com
Port: 8080
Path: /homepage.html
Use of uninitialized value at ./testURL.pl line 33.
Use of uninitialized value at ./testURL.pl line 33.
Use of uninitialized value at ./testURL.pl line 33.
Use of uninitialized value at ./testURL.pl line 33.
Use of uninitialized value at ./testURL.pl line 33.
Use of uninitialized value at ./testURL.pl line 33.
URL elements: http; myuser; mypass; www.foobar.com; 8080;
/homepage.html; ; ;

PS: I originally posted this message through work, but I don't think it made
out onto the internet. My apologies if you get this twice.

Thanks!

Andrew Robinson
--

Amoco Corporation                      phone: (504) 586-6888
New Orleans, LA                          fax: (504) 586-2637
-----
The events depicted herein are fictional. Any similarity to
persons living or dead is entirely...oops, wrong disclaimer

Andrew Robinson
---
Disclaimer: The opinions expressed are mine alone and do not represent the
views of America Online



Tue, 12 Dec 2000 03:00:00 GMT  
 Newbie URI::URL question

Quote:

> I'm trying to understand  the URI::URL module  with this simple program. Seems
> I do not understand the user and password constructs, which I think I need to
> to be able to write an LWP program that will get past my company's firewall.

HTTP URLs do not really support the user/password.  Perhaps you just
should set the Authorization header in the request.  The lwpcook
manpage contains this program example:

  use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $req = new HTTP::Request GET => 'http://www.sn.no/secret/';
  $req->authorization_basic('user', 'mypassword');
  print $ua->request($req)->as_string;

and if the firewall is a HTTP proxy server you might want to use
something like this:

 use LWP::UserAgent;

 $ua = new LWP::UserAgent;
 $ua->proxy(['http', 'ftp'] => 'http://proxy.myorg.com');

 $req = new HTTP::Request 'GET',"http://www.perl.com";
 $req->proxy_authorization_basic("proxy_user", "proxy_password");

 $res = $ua->request($req);
 print $res->content if $res->is_success;

--
Gisle Aas



Wed, 13 Dec 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newbie URI::URL question

2. URI:: URL Question

3. Question about the URI::URL module

4. Question about the URI::URL module

5. URI::URL module question

6. URI::URL module

7. URI::URL and FILE::BASENAME???????????????

8. Looking for advice on using URL::URI module

9. URI::URL 3.00 released

10. weird behavior with URI::URL

11. URI::URL

12. how to use URI::URL ?

 

 
Powered by phpBB® Forum Software