]> Sergey Matveev's repositories - public-inbox.git/blobdiff - t/httpd-corner.psgi
remove Email::Address dependency
[public-inbox.git] / t / httpd-corner.psgi
index 349b35dfb22d32df1096af54cba0f4001b19f7b0..222b9e01a058bd82cd102ba46a03957de92c4eef 100644 (file)
@@ -30,6 +30,7 @@ my $app = sub {
                        return sub {
                                open my $f, '<', $fifo or
                                                die "open $fifo: $!\n";
+                               local $/ = "\n";
                                my @r = <$f>;
                                $_[0]->([200, $h, \@r ]);
                        };
@@ -38,6 +39,7 @@ my $app = sub {
                                my $fh = $_[0]->([200, $h]);
                                open my $f, '<', $fifo or
                                                die "open $fifo: $!\n";
+                               local $/ = "\n";
                                while (defined(my $l = <$f>)) {
                                        $fh->write($l);
                                }
@@ -47,6 +49,17 @@ my $app = sub {
        } elsif ($path eq '/host-port') {
                $code = 200;
                push @$body, "$env->{REMOTE_ADDR}:$env->{REMOTE_PORT}";
+       } elsif ($path eq '/callback') {
+               return sub {
+                       my ($res) = @_;
+                       my $buf = "hello world\n";
+                       push @$h, 'Content-Length', length($buf);
+                       my $fh = $res->([200, $h]);
+                       $fh->write($buf);
+                       $fh->close;
+               }
+       } elsif ($path eq '/empty') {
+               $code = 200;
        }
 
        [ $code, $h, $body ]