From: Sebastian Riedel Date: Sun, 20 Mar 2005 18:00:47 +0000 (+0000) Subject: added connection stuff X-Git-Tag: 5.7099_04~1756 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0556eb49954590b794221ed3a033565c85dbeb32;p=catagits%2FCatalyst-Runtime.git added connection stuff --- diff --git a/Changes b/Changes index 043c1ca..01bee69 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ This file documents the revision history for Perl extension Catalyst. +4.30 XXX XXX XX XX:00:00 2005 + - added connection informations (Christian Hansen) + 4.28 Sat Mar 19 22:00:00 2005 - fixed isa tree (Christian Hansen) - added script/cgi-server.pl, so no more server restarting after diff --git a/MANIFEST b/MANIFEST index 83a8914..e26067b 100644 --- a/MANIFEST +++ b/MANIFEST @@ -34,3 +34,4 @@ t/10redirect.t t/11stash.t t/12default.t t/13beginend.t +t/14connection.t diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 98c8776..3182f94 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -7,7 +7,7 @@ use Catalyst::Log; __PACKAGE__->mk_classdata($_) for qw/_config log/; -our $VERSION = '4.28'; +our $VERSION = '4.30'; our @ISA; =head1 NAME diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 7395270..38d8aef 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -124,7 +124,6 @@ sub action { } } - =item $c->benchmark($coderef) Takes a coderef with arguments and returns elapsed time as float. @@ -491,9 +490,13 @@ sub prepare { $c->prepare_path; $c->prepare_cookies; $c->prepare_headers; - my $method = $c->req->method || ''; - my $path = $c->req->path || ''; - $c->log->debug(qq/"$method" request for "$path"/) if $c->debug; + $c->prepare_connection; + my $method = $c->req->method || ''; + my $path = $c->req->path || ''; + my $hostname = $c->req->hostname || ''; + my $address = $c->req->address || ''; + $c->log->debug(qq/"$method" request for "$path" from $hostname($address)/) + if $c->debug; $c->prepare_action; $c->prepare_parameters; @@ -562,6 +565,14 @@ sub prepare_action { if ( $c->debug && @args ); } +=item $c->prepare_connection; + +Prepare connection. + +=cut + +sub prepare_connection { } + =item $c->prepare_cookies; Prepare cookies. diff --git a/lib/Catalyst/Engine/Apache.pm b/lib/Catalyst/Engine/Apache.pm index 55d8e89..aca61ad 100644 --- a/lib/Catalyst/Engine/Apache.pm +++ b/lib/Catalyst/Engine/Apache.pm @@ -9,6 +9,7 @@ use URI; # mod_perl if (MP2) { require Apache2; + require Apache::Connection; require Apache::RequestIO; require Apache::RequestRec; require Apache::SubRequest; @@ -96,6 +97,16 @@ sub finalize_output { $c->original_request->print( $c->response->{output} ); } +=item $c->prepare_connection + +=cut + +sub prepare_connection { + my $c = shift; + $c->req->hostname( $c->apache_request->connection->remote_host ); + $c->req->address( $c->apache_request->connection->remote_ip ); +} + =item $c->prepare_cookies =cut diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 1efa954..e944526 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -106,6 +106,16 @@ sub finalize_output { print $c->response->output; } +=item $c->prepare_connection + +=cut + +sub prepare_connection { + my $c = shift; + $c->req->hostname( $c->cgi->remote_host ); + $c->req->address( $c->cgi->remote_addr ); +} + =item $c->prepare_cookies Sets up cookies. diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index f6ad5a6..f06e27e 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -4,8 +4,8 @@ use strict; use base 'Class::Accessor::Fast'; __PACKAGE__->mk_accessors( - qw/action arguments base cookies headers match method parameters path - snippets uploads/ + qw/action address arguments base cookies headers hostname match method + parameters path snippets uploads/ ); *args = \&arguments; @@ -31,6 +31,12 @@ Contains the action. print $c->request->action; +=head3 address + +Contains the remote address. + + print $c->request->address + =head3 arguments (args) Returns an arrayref containing the arguments. @@ -53,6 +59,12 @@ Returns a L object containing the headers. print $c->request->headers->header('X-Catalyst'); +=head3 hostname + +Contains the remote hostname. + + print $c->request->hostname + =head3 match Contains the match.