Skip to content

Commit

Permalink
small optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Nov 20, 2012
1 parent 6c84566 commit 6313575
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/Mojo/Message/Request.pm
Expand Up @@ -154,16 +154,17 @@ sub params {

sub parse {
my $self = shift;
my $env = @_ > 1 ? {@_} : ref $_[0] eq 'HASH' ? $_[0] : undef;
my @args = $env ? undef : @_;

# CGI like environment
# Parse CGI like environment
my $env = @_ > 1 ? {@_} : ref $_[0] eq 'HASH' ? $_[0] : undef;
$self->env($env)->_parse_env($env) if $env;
my $cgi = ($self->{state} // '') eq 'cgi';
$self->content($self->content->parse_body(@args)) if $cgi;

# Pass through for normal requests
$self->SUPER::parse($cgi ? undef : @args);
# Parse normal message
my @args = $env ? undef : @_;
if (($self->{state} // '') ne 'cgi') { $self->SUPER::parse(@args) }

# Parse CGI content
else { $self->content($self->content->parse_body(@args))->SUPER::parse }

# Check if we can fix things that require all headers
return $self unless $self->is_finished;
Expand Down Expand Up @@ -261,7 +262,7 @@ sub _parse_env {
$path->parse($buffer);
}

# Bypass normal content parser
# Bypass normal message parser
$self->{state} = 'cgi';
}

Expand Down

0 comments on commit 6313575

Please sign in to comment.