+sub check_400 {
+ my ($conn) = @_;
+ my $r = $conn->read(my $buf, 8192);
+ # ECONNRESET and $r==0 are both observed on FreeBSD 11.2
+ if (!defined($r)) {
+ ok($!{ECONNRESET}, 'ECONNRESET on read (BSD sometimes)');
+ } elsif ($r > 0) {
+ like($buf, qr!\AHTTP/1\.\d 400 !, 'got 400 response');
+ } else {
+ is($r, 0, 'got EOF (BSD sometimes)');
+ }
+ close($conn); # ensure we don't get SIGPIPE later
+}
+
+{
+ local $SIG{PIPE} = 'IGNORE';