diff options
Diffstat (limited to 'test/perl')
-rw-r--r-- | test/perl/body_io_fake/IOFake.pm | 33 | ||||
-rw-r--r-- | test/perl/body_io_fake/psgi.pl | 11 | ||||
-rw-r--r-- | test/perl/delayed_response/psgi.pl | 10 | ||||
-rw-r--r-- | test/perl/streaming_body/psgi.pl | 13 |
4 files changed, 67 insertions, 0 deletions
diff --git a/test/perl/body_io_fake/IOFake.pm b/test/perl/body_io_fake/IOFake.pm new file mode 100644 index 00000000..d2542aa5 --- /dev/null +++ b/test/perl/body_io_fake/IOFake.pm @@ -0,0 +1,33 @@ +package IOFake; + +sub new { + my $class = shift; + my $errors = shift; + my $self = {}; + + $self->{_count} = 2; + $self->{_errors} = $errors; + + bless $self, $class; + return $self; +} + +sub getline() { + my $self = shift; + + if ($self->{_count} > 0) { + return $self->{_count}--; + } + + $self->{_errors}->print('IOFake getline() $/ is ' . ${ $/ }); + + return; +} + +sub close() { + my $self = shift; + + $self->{_errors}->print('IOFake close() called'); +}; + +1; diff --git a/test/perl/body_io_fake/psgi.pl b/test/perl/body_io_fake/psgi.pl new file mode 100644 index 00000000..6990bfaf --- /dev/null +++ b/test/perl/body_io_fake/psgi.pl @@ -0,0 +1,11 @@ +use File::Basename; +use lib dirname (__FILE__); +use IOFake; + +my $app = sub { + my ($environ) = @_; + + my $io = IOFake->new($environ->{'psgi.errors'}); + + return ['200', [ 'Content-Length' => '2' ], $io]; +}; diff --git a/test/perl/delayed_response/psgi.pl b/test/perl/delayed_response/psgi.pl new file mode 100644 index 00000000..f934c3a7 --- /dev/null +++ b/test/perl/delayed_response/psgi.pl @@ -0,0 +1,10 @@ +my $app = sub { + my ($environ) = @_; + + return sub { + (my $responder = shift)->([200, [ + 'Content-Type' => 'text/plain', + 'Content-Length' => '12' + ], ["Hello World!"]]); + } +}; diff --git a/test/perl/streaming_body/psgi.pl b/test/perl/streaming_body/psgi.pl new file mode 100644 index 00000000..a3e54ee0 --- /dev/null +++ b/test/perl/streaming_body/psgi.pl @@ -0,0 +1,13 @@ +my $app = sub { + my ($environ) = @_; + + return sub { + my $writer = (my $responder = shift)->([200, [ + 'Content-Type' => 'text/plain', + 'Content-Length' => '12' + ]]); + + $writer->write("Hello World!"); + $writer->close; + }; +}; |