Fixed crash on retrieving the remote IP for: &a_href_cz
authorshort <>
Sun, 18 Sep 2005 07:21:51 +0000 (07:21 +0000)
committershort <>
Sun, 18 Sep 2005 07:21:51 +0000 (07:21 +0000)
Web.pm

diff --git a/Web.pm b/Web.pm
index f9d6d62..5c2dd07 100644 (file)
--- a/Web.pm
+++ b/Web.pm
@@ -121,6 +121,7 @@ require Data::Compare;
 use Data::Dumper;
 require Encode;
 use Apache2::Filter;
+use Apache2::Connection;
 
 
 #our $W;
@@ -237,7 +238,7 @@ my($class,%args)=@_;
        $W->{"headers_in"}=My::Hash::Merge->new(
                        $W->{"headers_in"},
                        My::Hash::Sub->new({
-                               "_get_remote_host"=>sub { return $W->{"r"}->get_remote_host(); },
+                               "_remote_ip"=>sub { return $W->{"r"}->connection()->remote_ip(); },
                                }),
                        );
        $W->{"headers_in"}=My::Hash::Readonly->new($W->{"headers_in"});
@@ -671,7 +672,7 @@ sub remote_ip ()
        # As 'Apache2::ForwardedFor' takes the first of $ENV{"HTTP_X_FORWARDED_FOR"}
        # while the contents is '127.0.0.1, 213.220.195.171' if client has its own proxy.
        # We must take the last item ourselves.
-       my $r=$W->{"headers_in"}{"X-Forwarded-For"} || $W->{"headers_in"}{"_get_remote_host"};
+       my $r=$W->{"headers_in"}{"X-Forwarded-For"} || $W->{"headers_in"}{"_remote_ip"};
        $r=~s/^.*,\s*//;
        return $r;
 }