Permalink
Browse files

Added a seek once again, so that the apps in between might read input…

… without seeking back
  • Loading branch information...
1 parent 9d0bcd2 commit a96a5b6e112a53b974becdd1a85dea9fbb79816e @miyagawa miyagawa committed Nov 15, 2012
Showing with 12 additions and 1 deletion.
  1. +2 −0 lib/Plack/Request.pm
  2. +10 −1 t/Plack-Request/content.t
View
@@ -92,6 +92,8 @@ sub content {
my $fh = $self->input or return '';
my $cl = $self->env->{CONTENT_LENGTH} or return'';
+
+ $fh->seek(0, 0); # just in case middleware/apps read it without seeking back
$fh->read(my($content), $cl, 0);
$fh->seek(0, 0);
View
@@ -5,8 +5,17 @@ use Plack::Test;
use Plack::Request;
my $app = sub {
- my $req = Plack::Request->new(shift);
+ my $env = shift;
+
+ my $req = Plack::Request->new($env);
is $req->content, 'body';
+
+ # emulate other PSGI apps that reads from input, but not reset
+ $env->{'psgi.input'}->read(my($dummy), $env->{CONTENT_LENGTH}, 0);
+
+ $req = Plack::Request->new($env);
+ is $req->content, 'body';
+
$req->new_response(200)->finalize;
};

0 comments on commit a96a5b6

Please sign in to comment.