Got a Software error:
[Fri Apr 22 17:20:23 2005] [14536] Can't call method "url" on an undef +ined value at /home/www/thehost.superihost.com/cgi-bin/helper.pl line + 45.
What is problem, what should be corrected?

#!/usr/bin/perl -Tw use CGI::Carp qw(fatalsToBrowser); use strict; $ENV{PATH} = join ":", qw(/usr/ucb /bin /usr/bin); $|++; ## Copyright (c) 1996 by Randal L. Schwartz ## This program is free software; you can redistribute it ## and/or modify it under the same terms as Perl itself. ## Anonymous HTTP proxy (handles http:, gopher:, ftp:) ## requires LWP 5.04 or later my $HOST = "localhost"; my $PORT = "8008"; sub prefix { my $now = localtime; join "", map { "[$now] [${$}] $_\n" } split /\n/, join "", @_; } $SIG{__WARN__} = sub { warn prefix @_ }; $SIG{__DIE__} = sub { die prefix @_ }; $SIG{CLD} = $SIG{CHLD} = sub { wait; }; my $AGENT; # global user agent (for efficiency) BEGIN { use LWP::UserAgent; @MyAgent::ISA = qw(LWP::UserAgent); # set inheritance $AGENT = MyAgent->new; $AGENT->agent("anon/0.07"); $AGENT->env_proxy; } sub MyAgent::redirect_ok { 0 } # redirects should pass through { ### MAIN ### use HTTP::Daemon; my $master = new HTTP::Daemon LocalAddr => $HOST, LocalPort => $PORT; warn "set your proxy to <URL:", $master->url, ">"; my $slave; &handle_connection($slave) while $slave = $master->accept; exit 0; } ### END MAIN ### sub handle_connection { my $connection = shift; # HTTP::Daemon::ClientConn my $pid = fork; if ($pid) { # spawn OK, and I'm the parent close $connection; return; } ## spawn failed, or I'm a good child my $request = $connection->get_request; if (defined($request)) { my $response = &fetch_request($request); $connection->send_response($response); close $connection; } exit 0 if defined $pid; # exit if I'm a good child with a good + parent } sub fetch_request { my $request = shift; # HTTP::Request use HTTP::Response; my $url = $request->url; warn "fetching $url"; if ($url->scheme !~ /^(http|gopher|ftp)$/) { my $res = HTTP::Response->new(403, "Forbidden"); $res->content("bad scheme: @{[$url->scheme]}\n"); $res; } elsif (not $url->rel->netloc) { my $res = HTTP::Response->new(403, "Forbidden"); $res->content("relative URL not permitted\n"); $res; } else { &fetch_validated_request($request); } } sub fetch_validated_request { # return HTTP::Response my $request = shift; # HTTP::Request ## uses global $AGENT ## warn "orig request: <<<", $request->headers_as_string, ">>>"; $request->remove_header(qw(User-Agent From Referer Cookie)); ## warn "anon request: <<<", $request->headers_as_string, ">>>"; my $response = $AGENT->request($request); ## warn "orig response: <<<", $response->headers_as_string, ">>>"; $response->remove_header(qw(Set-Cookie)); ## warn "anon response: <<<", $response->headers_as_string, ">>>"; $response; }

Janitored by Arunbear - added readmore tags, as per Monastery guidelines


In reply to Can't call method "url" by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.