Hi Jason. Jason Chinnes wrote: > > I am using mod_perl with Apache 1.3 (Win32) and am having difficulty > with the following code. > > ---------- > use CGI; > use Data::Dumper; > use HTTP::Request; > use LWP::UserAgent; > > my $q = new CGI; > $ua = new LWP::UserAgent; > $site = 'http://www.example.com/'; > print $q->header; # create the HTTP header > $request = new HTTP::Request GET => $site; > $response = $ua->request($request); > print $response->content; > ----------
You're getting a confused here. The CGI module is for server-side applications while LWP is client-side. If all you're doing is trying to fetch a file from the Internet then the above reduces to: use strict; use warnings; use LWP::UserAgent; my $ua = new LWP::UserAgent; my $site = 'http://www.example.com/'; my $response = $ua->get($site); print $response->content; Printing an HTTP header to STDOUT has no useful purpose at all. > This works fine when $site = 'http://www.example.com/' or anything else > that's not on my server. When it is on my server (say > 'http://localhost/') the client hangs. Apache's access.log file lists: It sounds like your local machine isn't an HTTP server. If that's the case then just use the file 'protocol' instead: my $site = 'file:/home/rob/test.txt'; > 127.0.0.1 - - [08/Dec/2003:16:57:30 -0500] "GET / HTTP/1.1" 200 3337 > > But, this file never seems to make it back to my script. > http://localhost/ comes up fine in a browser, and when I telnet in and > make the request manually. Now it looks like you /are/ in fact living on an HTTP server. But you need to find the scope of directories that Apache will serve. Have you tried my $site = 'http://localhost/'; without any explicit filename? That should bring in the default 'index.htm' (or whatever). HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>