use Moose;
+use namespace::clean -except => 'meta';
+
with 'MooseX::Emulate::Class::Accessor::Fast';
has action => (is => 'rw');
has secure => (is => 'rw', default => 0);
has captures => (is => 'rw', default => sub { [] });
has uri => (is => 'rw', predicate => 'has_uri');
-has user => (is => 'rw');
+has remote_user => (is => 'rw');
has headers => (
is => 'rw',
isa => 'HTTP::Headers',
has uploads => (
is => 'rw',
required => 1,
- lazy => 1,
default => sub { {} },
);
);
has _body => (
- is => 'rw',
- accessor => 'body',
+ is => 'rw', clearer => '_clear_body', predicate => '_has_body',
);
-
-before body => sub {
- my ($self) = @_;
+# Eugh, ugly. Should just be able to rename accessor methods to 'body'
+# and provide a custom reader..
+sub body {
+ my $self = shift;
$self->_context->prepare_body();
-};
+ $self->_body(@_) if scalar @_;
+ return blessed $self->_body ? $self->_body->body : $self->_body;
+}
has hostname => (
is => 'rw',
has _path => ( is => 'rw', predicate => '_has_path', clearer => '_clear_path' );
-no Moose;
+# XXX: Deprecated in 5.8000 due to confusion between Engines and Plugin::Authentication. Remove in 5.x000?
+has user => (is => 'rw');
+
+before user => sub {
+ my ($self, $user) = @_;
+ # Allow Engines and Plugin::Authentication to set without warning
+ my $caller = (caller(2))[0];
+ if ( $caller !~ /^Catalyst::(Engine|Plugin::Authentication)/ ) {
+ $self->_context->log->warn(
+ 'Attempt to use $c->req->user; this is deprecated. ' .
+ 'You probably meant to call $c->user or $c->req->remote_user' );
+ }
+};
sub args { shift->arguments(@_) }
sub body_params { shift->body_parameters(@_) }
and the URI for the request was C<http://.../foo/moose/bah>, the string C<bah>
would be the first and only argument.
+Arguments just get passed through and B<don't> get unescaped automatically, so
+you should do that explicitly.
+
=head2 $req->args
Shortcut for arguments.
=head2 $req->path_info
-Alias for path, added for compability with L<CGI>.
+Alias for path, added for compatibility with L<CGI>.
=cut
=head2 $req->snippets
-C<captures> used to be called snippets. This is still available for backwoards
+C<captures> used to be called snippets. This is still available for backwards
compatibility, but is considered deprecated.
=head2 $req->upload
Returns the currently logged in user. Deprecated. The method recommended for
newer plugins is $c->user.
+=head2 $req->remote_user
+
+Returns the value of the C<REMOTE_USER> environment variable. Previously
+available via $req->user.
+
=head2 $req->user_agent
Shortcut to $req->headers->user_agent. Returns the user agent (browser)