Bug#710477:

Chris Denley cdenley1 at gmail.com
Mon Dec 2 02:53:00 GMT 2019


Putting a simple test script together, I found my problem. The client_ip
method doesn't work on Apache2::Connection objects unless the
Apache2::Connection module is loaded in the current namespace.

package test;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Const -compile => 'OK';

sub handler {
   my $r = shift;
   $r->content_type('text/plain');
   my $ref = ref($r);
   print "ref(\$r) = $ref\n";
   my $conn = $r->connection;
   $ref = ref($conn);
   print "ref(\$conn) = $ref\n";
   for(1..2) {
      if($_==2) {
         print "require Apache2::Connection\n";
         require Apache2::Connection;
      }
      if($conn->can('client_ip')) {
         print "client_ip: ".$conn->client_ip."\n";
      }
      else {
         print "\$conn cannot client_ip\n";
      }
      if($conn->can('remote_ip')) {
         print "remote_ip: ".$conn->remote_ip."\n";
      }
      else {
         print "\$conn cannot remote_ip\n";
      }
   }
   return Apache2::Const::OK;
}
1;

ref($r) = Apache2::RequestRec
ref($conn) = Apache2::Connection
$conn cannot client_ip
$conn cannot remote_ip
require Apache2::Connection
client_ip: 127.0.0.1
$conn cannot remote_ip


On Thu, 28 Nov 2019 22:44:26 +0200 Damyan Ivanov <dmn at debian.org> wrote:
> -=| Chris Denley, 28.11.2019 08:02:52 -0600 |=-
> > client_ip and remote_ip do not work. Is there no way to get this value
anymore?
> >
> > Can't locate object method "remote_ip" via package "Apache2::Connection"
> > Can't locate object method "client_ip" via package "Apache2::Connection"
> > Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 mod_apreq2-20090110/2.8.0
mod_perl/2.0.10
> > Perl/v5.26.1
>
> the following works for me:
>
>     my $conn = $r->connection;
>
>     my $ip_addr
>         = $conn->can('client_ip')
>         ? $conn->client_ip
>         : $conn->remote_ip;
>
> so one of them works, and I bet it is 'client_ip'
>
> (Debian/sid and Debian/buster (and several releases before that))
>
> Can you share the code that fails for you?
>
> -- Damyan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-perl-maintainers/attachments/20191201/6c21a1f7/attachment.html>


More information about the pkg-perl-maintainers mailing list