Confusion over Apache2::Request and Apache2::RequestRec
--000e0cd48b58e9f81304718d9795
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
I'm confused about something and I wonder if anyone can help me to
understand what's going on. The code shown below works fine but as I was
looking over this before changing something else I realized that it probably
shouldn't. I'm using an Apache2::Request object to return a connection
object to get the remote_ip but the documentation for Apache2::Request
doesn't show a connection method - that's in Apache2::RequestRec.
Why does connection() work on an Apache2::Request object?
Thanks!
-Doug
Apache2::Request:
http://httpd.apache.org/apreq/docs/libapreq2/group__apreq__x s__request.html
Apache2::RequestRec:
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html# C_connection_
In the PerlResponseHandler:
my $requestrec = shift if $ENV{MOD_PERL};
my $request = Apache2::Request->new($requestrec);
my $session = Sessions->new($request, $mysql);
{package Sessions;
sub new {
my $class=shift;
my $self={};
bless ($self, $class);
$self->{REQUEST}=shift;
$self->{DBH}=shift;
{...snip...}
$self->{DBH}->do('INSERT INTO failedloginattempts (username,
password, ip, session, attempttime) VALUES
('.$self->{DBH}->quote($username).','.$self->{DBH}->quote($p assword).',
INET_ATON('.$self->{DBH}->quote(*$self->{REQUEST}->connectio n()->remote_ip*).'),
'.$self->{DBH}->quote($self->{SESSION}).', NOW())');
--000e0cd48b58e9f81304718d9795
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<br>I'm confused about something and I wonder if anyone can help me to =
understand what's going on.=A0 The code shown below works fine but as I=
was looking over this before changing something else I realized that it pr=
obably shouldn't.=A0 I'm using an Apache2::Request object to return=
a connection object to get the remote_ip but the documentation for Apache2=
::Request doesn't show a connection method - that's in Apache2::Req=
uestRec.<br>
<br>Why does connection() work on an Apache2::Request object?<br><br>Thanks=
!<br><br>-Doug<br><br><br>Apache2::Request: <a href=3D"http://httpd.apache.=
org/apreq/docs/libapreq2/group__apreq__xs__request.html">htt p://httpd.apach=
e.org/apreq/docs/libapreq2/group__apreq__xs__request.html</a><br>
Apache2::RequestRec: <a href=3D"http://perl.apache.org/docs/2.0/api/Apache2=
/RequestRec.html#C_connection_">http://perl.apache.org/docs/ 2.0/api/Apache2=
/RequestRec.html#C_connection_</a><br><br><br>In the PerlResponseHandler:<b=
r>
<br>=A0 my $requestrec =3D shift if $ENV{MOD_PERL};<br>=A0 my $request =3D =
Apache2::Request->new($requestrec);<br>=A0 my $session =3D Sessions->=
new($request, $mysql);<br><br><br><br>{package Sessions;<br><br>=A0 sub new=
{<br>=A0=A0=A0 my $class=3Dshift;<br>
=A0=A0=A0 my $self=3D{};<br>=A0=A0=A0 bless ($self, $class);<br><br>=A0=A0=
=A0 $self->{REQUEST}=3Dshift;<br>=A0=A0=A0 $self->{DBH}=3Dshift;<br><=
br>{...snip...}<br><br>=A0=A0=A0=A0=A0=A0=A0 $self->{DBH}->do('IN=
SERT INTO failedloginattempts (username, password, ip, session, attempttime=
) VALUES ('.$self->{DBH}->quote($username).','.$self->=
{DBH}->quote($password).', INET_ATON('.$self->{DBH}->quote=
(<b>$self->{REQUEST}->connection()->remote_ip</b>).'), '.$=
self->{DBH}->quote($self->{SESSION}).', NOW())');<br>
<br><br>
--000e0cd48b58e9f81304718d9795--
Re: Confusion over Apache2::Request and Apache2::RequestRec
--0-1511524103-1250753189=:28890
Content-Type: text/plain; charset=us-ascii
Apache2::Request is a derived class of Apache2::RequestRec,
so what you're doing is perfectly ok.
>
>From: Douglas Sims <ratsbane [at] gmail.com>
>To: modperl <modperl [at] perl.apache.org>
>Sent: Thursday, August 20, 2009 3:20:59 AM
>Subject: Confusion over Apache2::Request and Apache2::RequestRec
>
>
>I'm confused about something and I wonder if anyone can help me to understand what's going on. The code shown below works fine but as I was looking over this before changing something else I realized that it probably shouldn't. I'm using an Apache2::Request object to return a connection object to get the remote_ip but the documentation for Apache2::Request doesn't show a connection method - that's in Apache2::RequestRec.
>
>Why does connection() work on an Apache2::Request object?
>
>Thanks!
>
>-Doug
>
>
>Apache2::Request: http://httpd.apache.org/apreq/docs/libapreq2/group__apreq__x s__request.html
>>Apache2::RequestRec: http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html# C_connection_
>
>
>In the PerlResponseHandler:
>
> my $requestrec = shift if $ENV{MOD_PERL};
> my $request = Apache2::Request->new($requestrec);
> my $session = Sessions->new($request, $mysql);
>
>
>
>{package Sessions;
>
> sub new {
> my $class=shift;
>> my $self={};
> bless ($self, $class);
>
> $self->{REQUEST}=shift;
> $self->{DBH}=shift;
>
>{...snip...}
>
> $self->{DBH}->do('INSERT INTO failedloginattempts (username, password, ip, session, attempttime) VALUES ('.$self->{DBH}->quote($username).','.$self->{DBH}->quote($p assword).', INET_ATON('.$self->{DBH}->quote($self->{REQUEST}->connection ()->remote_ip).'), '.$self->{DBH}->quote($self->{SESSION}).', NOW())');
>
>
>
--0-1511524103-1250753189=:28890
Content-Type: text/html; charset=us-ascii
<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:courier,monaco,monospace,sans-serif;font-size:12pt"><div>Apache2::Request is a derived class of Apache2::RequestRec,<br>so what you're doing is perfectly ok.<br><br></div><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-family: courier,monaco,monospace,sans-serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><b><span style="font-weight: bold;">From:</span></b> Douglas Sims <ratsbane [at] gmail.com><br><b><span style="font-weight: bold;">To:</span></b> modperl <modperl [at] perl.apache.org><br><b><span style="font-weight: bold;">Sent:
</span></b> Thursday, August 20, 2009 3:20:59 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Confusion over Apache2::Request and
Apache2::RequestRec<br></font><br>
<meta http-equiv="x-dns-prefetch-control" content="off"><br>I'm confused about something and I wonder if anyone can help me to understand what's going on. The code shown below works fine but as I was looking over this before changing something else I realized that it probably shouldn't. I'm using an Apache2::Request object to return a connection object to get the remote_ip but the documentation for Apache2::Request doesn't show a connection method - that's in Apache2::RequestRec.<br>
<br>Why does connection() work on an Apache2::Request object?<br><br>Thanks!<br><br>-Doug<br><br><br><span>Apache2::Request: <a target="_blank" href="http://httpd.apache.org/apreq/docs/libapreq2/group__apreq__xs__request.html"> http://httpd.apache.org/apreq/docs/libapreq2/group__apreq__x s__request.html</a></span><br><span>
Apache2::RequestRec: <a target="_blank" href="http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html#C_connection_"> http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html# C_connection_</a></span><br><br><br>In the PerlResponseHandler:<br>
<br> my $requestrec = shift if $ENV{MOD_PERL};<br> my $request = Apache2::Request->new($requestrec);<br> my $session = Sessions->new($request, $mysql);<br><br><br><br>{package Sessions;<br><br> sub new {<br> my $class=shift;<br>
my $self={};<br> bless ($self, $class);<br><br> $self->{REQUEST}=shift;<br> $self->{DBH}=shift;<br><br>{...snip...}<br><br> $self->{DBH}->do('INSERT INTO failedloginattempts (username, password, ip, session, attempttime) VALUES ('.$self->{DBH}->quote($username).','.$self->{DBH}->quote($password).', INET_ATON('.$self->{DBH}->quote(<b>$self->{REQUEST}->connection()->remote_ip</b>).'), '.$self->{DBH}->quote($self->{SESSION}).', NOW())');<br>
<br><br>
<meta http-equiv="x-dns-prefetch-control" content="on"></div></div></blockquote></div><br>
</body></html>
--0-1511524103-1250753189=:28890--