-
-
Save anonymous/0eba6868f2c64af665d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Transaction.pm b/lib/Mojo/Transaction.pm | |
index 7bafadd..67f255a 100644 | |
--- a/lib/Mojo/Transaction.pm | |
+++ b/lib/Mojo/Transaction.pm | |
@@ -10,22 +10,7 @@ has [ | |
has req => sub { Mojo::Message::Request->new }; | |
has res => sub { Mojo::Message::Response->new }; | |
-sub client_close { | |
- my ($self, $close) = @_; | |
- | |
- # Premature connection close | |
- my $res = $self->res->finish; | |
- if ($close && !$res->code && !$res->error) { | |
- $res->error({message => 'Premature connection close'}); | |
- } | |
- | |
- # 4xx/5xx | |
- elsif ($res->is_status_class(400) || $res->is_status_class(500)) { | |
- $res->error({message => $res->message, code => $res->code}); | |
- } | |
- | |
- $self->server_close; | |
-} | |
+sub client_close { shift->server_close(@_) } | |
sub connection { | |
my $self = shift; | |
diff --git a/lib/Mojo/Transaction/HTTP.pm b/lib/Mojo/Transaction/HTTP.pm | |
index b86fbf1..c77db09 100644 | |
--- a/lib/Mojo/Transaction/HTTP.pm | |
+++ b/lib/Mojo/Transaction/HTTP.pm | |
@@ -3,6 +3,23 @@ use Mojo::Base 'Mojo::Transaction'; | |
has [qw(next previous)]; | |
+sub client_close { | |
+ my ($self, $close) = @_; | |
+ | |
+ # Premature connection close | |
+ my $res = $self->res->finish; | |
+ if ($close && !$res->code && !$res->error) { | |
+ $res->error({message => 'Premature connection close'}); | |
+ } | |
+ | |
+ # 4xx/5xx | |
+ elsif ($res->is_status_class(400) || $res->is_status_class(500)) { | |
+ $res->error({message => $res->message, code => $res->code}); | |
+ } | |
+ | |
+ $self->server_close; | |
+} | |
+ | |
sub is_empty { !!(uc $_[0]->req->method eq 'HEAD' || $_[0]->res->is_empty) } | |
sub keep_alive { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment