diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-03-27 21:26:59 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2018-03-27 21:27:34 +0000 |
commit | 703490825ebf9e22e30ab79063a81f8476ad2a0c (patch) | |
tree | 5b436510dca8705187b221afcecb6e76c151b231 /lib | |
parent | 3e8a4842d3f0ec51bab024322a934b91ace6f4ed (diff) | |
download | public-inbox-703490825ebf9e22e30ab79063a81f8476ad2a0c.tar.gz |
This fails in the rare case we get a partial send() on "\r\n" when writing chunked HTTP responses out.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/HTTP.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index 3dd49be3..bc10814e 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -316,9 +316,12 @@ sub more ($$) { if (MSG_MORE && !$self->{write_buf_size}) { my $n = send($self->{sock}, $_[1], MSG_MORE); if (defined $n) { - my $dlen = length($_[1]); - return 1 if $n == $dlen; # all done! - $_[1] = substr($_[1], $n, $dlen - $n); + my $nlen = length($_[1]) - $n; + return 1 if $nlen == 0; # all done! + eval { $_[1] = substr($_[1], $n, $nlen) }; + if ($@) { # modification of read-only value: + return $self->write(substr($_[1], $n, $nlen)); + } # fall through to normal write: } } |