Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
small optimizations
  • Loading branch information
kraih committed May 10, 2013
1 parent 03f2b12 commit fe66d95
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/Mojolicious/Controller.pm
Expand Up @@ -42,19 +42,17 @@ sub AUTOLOAD {
sub DESTROY { }

sub cookie {
my ($self, $name, $value, $options) = @_;
$options ||= {};
my ($self, $name) = (shift, shift);

# Response cookie
if (defined $value) {
if (@_) {

# Cookie too big
my $cookie = {name => $name, value => shift, %{shift || {}}};
$self->app->log->error(qq{Cookie "$name" is bigger than 4096 bytes.})
if length $value > 4096;
if length $cookie->{value} > 4096;

# Create new cookie
$self->res->cookies(
Mojo::Cookie::Response->new(name => $name, value => $value, %$options));
$self->res->cookies(Mojo::Cookie::Response->new(%$cookie));
return $self;
}

Expand Down

0 comments on commit fe66d95

Please sign in to comment.