File Coverage

blib/lib/HTTP/Body/OctetStream.pm
Criterion Covered Total %
statement 20 20 100.0
branch 6 6 100.0
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 32 32 100.0


line stmt bran cond sub pod time code
1             package HTTP::Body::OctetStream;
2             $HTTP::Body::OctetStream::VERSION = '1.23';
3 10     10   69 use strict;
  10         22  
  10         551  
4 10     10   65 use base 'HTTP::Body';
  10         21  
  10         1907  
5 10     10   5863 use bytes;
  10         5303  
  10         80  
6              
7 10     10   10167 use File::Temp 0.14;
  10         259738  
  10         2809  
8              
9             =head1 NAME
10              
11             HTTP::Body::OctetStream - HTTP Body OctetStream Parser
12              
13             =head1 SYNOPSIS
14              
15             use HTTP::Body::OctetStream;
16              
17             =head1 DESCRIPTION
18              
19             HTTP Body OctetStream Parser.
20              
21             =head1 METHODS
22              
23             =over 4
24              
25             =item spin
26              
27             =cut
28              
29             sub spin {
30 8     8 1 15 my $self = shift;
31              
32 8 100       28 unless ( $self->body ) {
33 3         15 $self->body( File::Temp->new( DIR => $self->tmpdir ) );
34             }
35              
36 8 100       86 if ( my $length = length( $self->{buffer} ) ) {
37 7         41 $self->body->write( substr( $self->{buffer}, 0, $length, '' ), $length );
38             }
39              
40 8 100       142 if ( $self->length == $self->content_length ) {
41 3         8 seek( $self->body, 0, 0 );
42 3         17 $self->state('done');
43             }
44             }
45              
46             =back
47              
48             =head1 SUPPORT
49              
50             See L<HTTP::Body>
51              
52             =head1 AUTHOR
53              
54             Christian Hansen, C<ch@ngmedia.com>
55              
56             =head1 LICENSE
57              
58             This library is free software . You can redistribute it and/or modify
59             it under the same terms as perl itself.
60              
61             =cut
62              
63             1;