diff options
author | Eric Wong <e@80x24.org> | 2019-07-04 10:02:06 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-07-04 10:16:41 +0000 |
commit | 620b5e23dded54e0abf954752767bc9683a882e3 (patch) | |
tree | 49fb41ae4e6d7d8cbdf26f0b0422c874d369ed31 /t | |
parent | 0f1da9d213e16946371b5c140b1c55b7231a8cd5 (diff) | |
download | public-inbox-620b5e23dded54e0abf954752767bc9683a882e3.tar.gz |
We need to ensure the BIN_DETECT (8000 byte) check in ViewVCS can be handled properly when sending giant files. Otherwise, EPOLLET won't notify us, again, and responses can get stuck. While we're at it, bump up the read-size up to 4096 bytes so we make fewer trips to the kernel.
Diffstat (limited to 't')
-rw-r--r-- | t/httpd-corner.psgi | 13 | ||||
-rw-r--r-- | t/httpd-corner.t | 16 |
2 files changed, 27 insertions, 2 deletions
diff --git a/t/httpd-corner.psgi b/t/httpd-corner.psgi index f8396907..9728aa05 100644 --- a/t/httpd-corner.psgi +++ b/t/httpd-corner.psgi @@ -72,6 +72,19 @@ my $app = sub { getline => sub { undef }, close => sub { die 'CLOSE FAIL' }, ); + } elsif ($path eq '/async-big') { + require PublicInbox::Qspawn; + open my $null, '>', '/dev/null' or die; + my $rdr = { 2 => fileno($null) }; + my $cmd = [qw(dd if=/dev/zero count=30 bs=1024k)]; + my $qsp = PublicInbox::Qspawn->new($cmd, undef, $rdr); + return $qsp->psgi_return($env, undef, sub { + my ($r, $bref) = @_; + # make $rd_hdr retry sysread + $parse_hdr in Qspawn: + return until length($$bref) > 8000; + close $null; + [ 200, [ qw(Content-Type application/octet-stream) ]]; + }); } [ $code, $h, $body ] diff --git a/t/httpd-corner.t b/t/httpd-corner.t index 5efb9d14..35318b50 100644 --- a/t/httpd-corner.t +++ b/t/httpd-corner.t @@ -251,9 +251,10 @@ SKIP: { $have_curl = 1; last; } - my $ntest = 2; + my $ntest = 4; $have_curl or skip('curl(1) missing', $ntest); - my $url = 'http://' . $sock->sockhost . ':' . $sock->sockport . '/sha1'; + my $base = 'http://' . $sock->sockhost . ':' . $sock->sockport; + my $url = "$base/sha1"; my ($r, $w); pipe($r, $w) or die "pipe: $!"; my $cmd = [qw(curl --tcp-nodelay --no-buffer -T- -HExpect: -sS), $url]; @@ -270,6 +271,17 @@ SKIP: { is($?, 0, 'curl exited successfully'); is($err, '', 'no errors from curl'); is($out, sha1_hex($str), 'read expected body'); + + open my $fh, '-|', qw(curl -sS), "$base/async-big" or die $!; + my $n = 0; + my $non_zero = 0; + while (1) { + my $r = sysread($fh, my $buf, 4096) or last; + $n += $r; + $buf =~ /\A\0+\z/ or $non_zero++; + } + is($n, 30 * 1024 * 1024, 'got expected output from curl'); + is($non_zero, 0, 'read all zeros'); } { |