Skip to content

Commit

Permalink
Make parse work without the Mojo::Content content_length hack
Browse files Browse the repository at this point in the history
I previously had a Mojo::Content hack but kraih says not to do
that[1] so instead we fake it here.

[1] mojolicious/mojo#575
  • Loading branch information
afresh1 committed Dec 28, 2013
1 parent b584ac9 commit 9d108bb
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/XDeadly/Post.pm
Expand Up @@ -36,13 +36,19 @@ has 'filename' => 'post';
has 'data_dir';

sub parse {
my $self = shift->SUPER::parse(@_);
my ( $self, $chunk ) = @_;

if (my $date = $self->headers->date) {
$self->_epoch( _parse_ctime($date) );
}
$self->content->on( body => sub {
my $content = shift;
my $headers = $content->headers;

return $self;
$headers->content_length( length $content->{pre_buffer} )
unless $headers->content_length;

$self->_epoch( _parse_ctime( $headers->date ) ) if $headers->date;
} );

return $self->SUPER::parse($chunk);
}

sub _parse_ctime {
Expand Down

0 comments on commit 9d108bb

Please sign in to comment.