Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

On bad_request, go through _write_psgi_response even if sending nothi…

…ng back
  • Loading branch information...
commit f9fbf8b99a4eb5cae433a1e68af46fd3bb31f44a 1 parent d5e803e
@athomason athomason authored
Showing with 15 additions and 11 deletions.
  1. +15 −11 lib/Twiggy/Server.pm
View
26 lib/Twiggy/Server.pm
@@ -160,7 +160,8 @@ sub _accept_handler {
1;
}) {
- $self->_bad_request($sock) unless $@ =~ /^client disconnected/;
+ my $disconnected = ($@ =~ /^client disconnected/);
+ $self->_bad_request($sock, $disconnected);
}
};
}
@@ -217,24 +218,27 @@ sub _create_req_parsing_watcher {
} catch {
undef $headers_io_watcher;
undef $timeout_timer;
- $self->_bad_request($sock) unless /^client disconnected/;
+ my $disconnected = /^client disconnected/;
+ $self->_bad_request($sock, $disconnected);
}
};
}
sub _bad_request {
- my ( $self, $sock ) = @_;
+ my ( $self, $sock, $disconnected ) = @_;
return unless defined $sock and defined fileno $sock;
- $self->_write_psgi_response(
- $sock,
- [
- 400,
- [ 'Content-Type' => 'text/plain' ],
- [ ],
- ],
- );
+ my $response = [
+ 400,
+ [ 'Content-Type' => 'text/plain' ],
+ [ ],
+ ];
+
+ # if client is already gone, don't try to write to it
+ $response = [] if $disconnected;
+
+ $self->_write_psgi_response($sock, $response);
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.