This saves us a system call for common GET/HEAD requests
with no upload body.
return recv_err($self, $r, $len) unless $r;
# continue looping if $r > 0;
}
return recv_err($self, $r, $len) unless $r;
# continue looping if $r > 0;
}
+ app_dispatch($self, $input);
-sub app_dispatch ($) {
- my ($self) = @_;
+sub app_dispatch {
+ my ($self, $input) = @_;
$self->watch_read(0);
my $env = $self->{env};
$env->{REMOTE_ADDR} = $self->{remote_addr};
$self->watch_read(0);
my $env = $self->{env};
$env->{REMOTE_ADDR} = $self->{remote_addr};
$host =~ s/:(\d+)\z// and $env->{SERVER_PORT} = $1;
$env->{SERVER_NAME} = $host;
}
$host =~ s/:(\d+)\z// and $env->{SERVER_PORT} = $1;
$env->{SERVER_NAME} = $host;
}
-
- sysseek($env->{'psgi.input'}, 0, SEEK_SET) or
+ if (defined $input) {
+ sysseek($input, 0, SEEK_SET) or
die "BUG: psgi.input seek failed: $!";
die "BUG: psgi.input seek failed: $!";
# note: NOT $self->{sock}, we want our close (+ Danga::Socket::close),
# to do proper cleanup:
$env->{'psgix.io'} = $self; # only for ->close
# note: NOT $self->{sock}, we want our close (+ Danga::Socket::close),
# to do proper cleanup:
$env->{'psgix.io'} = $self; # only for ->close
while (1) { # chunk start
if ($len == CHUNK_ZEND) {
while (1) { # chunk start
if ($len == CHUNK_ZEND) {
- return app_dispatch($self) if $$rbuf =~ s/\A\r\n//s;
+ $$rbuf =~ s/\A\r\n//s and
+ return app_dispatch($self, $input);
return quit($self, 400) if length($$rbuf) > 2;
}
if ($len == CHUNK_END) {
return quit($self, 400) if length($$rbuf) > 2;
}
if ($len == CHUNK_END) {