X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FRequest.pm;h=f6ffd4ef5e5688804607d8d2a56e0e68f0ee46a1;hb=479d2af43e49eb898f7453e9888e977f41b65c7c;hp=b63e48d3dfb4fc55d870b636eafe1a36fbdb0724;hpb=5ddd05a02d9532f0beefedd532e604c6f3bae4c8;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index b63e48d..f6ffd4e 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -4,95 +4,173 @@ 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; *params = \¶meters; +sub content_encoding { shift->headers->content_encoding(@_) } +sub content_length { shift->headers->content_length(@_) } +sub content_type { shift->headers->content_type(@_) } +sub header { shift->headers->header(@_) } +sub referer { shift->headers->referer(@_) } +sub user_agent { shift->headers->user_agent(@_) } + =head1 NAME Catalyst::Request - Catalyst Request Class =head1 SYNOPSIS -See L. + + $req = $c->request; + $req->action; + $req->address; + $req->args; + $req->arguments; + $req->base; + $req->content_encoding; + $req->content_length; + $req->content_type; + $req->cookies; + $req->header; + $req->headers; + $req->hostname; + $req->match; + $req->method; + $req->parameters; + $req->params; + $req->path; + $req->referer; + $req->snippets; + $req->uploads; + $req->user_agent + +See also L. =head1 DESCRIPTION -The Catalyst Request. +This is the Catalyst Request class, which provides a set of accessors to the +request data. The request object is prepared by the specialized Catalyst +Engine module thus hiding the details of the particular engine implementation. + + +=head1 METHODS -=head2 METHODS +=over 4 -=head3 action +=item $req->action Contains the action. print $c->request->action; -=head3 arguments (args) +=item $req->address + +Contains the remote address. + + print $c->request->address + +=item $req->arguments + +=item $req->args -Returns an arrayref containing the arguments. +Returns a reference to an array containing the arguments. print $c->request->arguments->[0]; -=head3 base +=item $req->base Contains the uri base. -=head3 cookies +=item $req->content_encoding -Returns a hashref containing the cookies. +Shortcut to $req->headers->content_encoding + +=item $req->content_length + +Shortcut to $req->headers->content_length + +=item $req->content_type + +Shortcut to $req->headers->content_type + +=item $req->cookies + +Returns a reference to a hash containing the cookies. print $c->request->cookies->{mycookie}->value; -=head3 headers +=item $req->header + +Shortcut to $req->headers->header -Returns a L object containing the headers. +=item $req->headers + +Returns an L object containing the headers. print $c->request->headers->header('X-Catalyst'); -=head3 match +=item $req->hostname + +Contains the remote hostname. + + print $c->request->hostname + +=item $req->match Contains the match. print $c->request->match; -=head3 parameters (params) +=item $req->method + +Contains the request method (C, C, C, etc). + + print $c->request->method + +=item $req->parameters + +=item $req->params -Returns a hashref containing the parameters. +Returns a reference to a hash containing the parameters. print $c->request->parameters->{foo}; -=head3 path +=item $req->path Contains the path. print $c->request->path; -=head3 method +=item $req->referer -Contains the request method. - - print $c->request->method +Shortcut to $req->headers->referer -=head3 snippets +=item $req->snippets -Returns an arrayref containing regex snippets. +Returns a reference to an array containing regex snippets. my @snippets = @{ $c->request->snippets }; -=head3 uploads +=item $req->uploads -Returns a hashref containing the uploads. +Returns a reference to a hash containing the uploads. my $filename = $c->req->parameters->{foo}; - print $c->request->uploads->{$filename}->type; - print $c->request->uploads->{$filename}->size; - my $fh = $c->request->uploads->{$filename}->fh; + print $c->request->uploads->{$filename}->{type}; + print $c->request->uploads->{$filename}->{size}; + my $fh = $c->request->uploads->{$filename}->{fh}; my $content = do { local $/; <$fh> }; +=item $req->user_agent + +Shortcut to $req->headers->user_agent + +=back + =head1 AUTHOR Sebastian Riedel, C