mojolicious / mojo-pg

Mojolicious :heart: PostgreSQL
https://metacpan.org/release/Mojo-Pg
Artistic License 2.0
99 stars 46 forks source link

Bug with calling callback after write data to client with content_length header #19

Closed Logioniz closed 8 years ago

Logioniz commented 8 years ago

In accordance with the documentation, I believe that callback should be called always. But when you set the content_length header, then the last callback is not invoked. Below is the test that shows this behavior.

#!/usr/bin/perl
use Mojolicious::Lite;
use Test::Mojo;
use Test::More;

get '/' => sub {
  my $c = shift->render_later;
  $c->res->headers->content_length(2);
  $c->write('11', sub { app->defaults(qwe => 1234); $c->finish });
};

app->start;

my $t = Test::Mojo->new;
$t->get_ok('/')->status_is(200);
is app->defaults('qwe'), 1234;

done_testing;

I believe that this is a bug, since it's not documented.