released 0.6
[catagits/HTTP-Body.git] / lib / HTTP / Body / OctetStream.pm
CommitLineData
4f5db602 1package HTTP::Body::OctetStream;
32b29b79 2
3use strict;
4use base 'HTTP::Body';
5use bytes;
6
7use File::Temp 0.14;
8
aac7ca02 9=head1 NAME
10
38ad3df8 11HTTP::Body::OctetStream - HTTP Body OctetStream Parser
aac7ca02 12
13=head1 SYNOPSIS
14
15 use HTTP::Body::OctetStream;
16
17=head1 DESCRIPTION
18
19HTTP Body OctetStream Parser.
20
21=head1 METHODS
22
23=over 4
24
25=item spin
26
27=cut
28
58050177 29sub spin {
30 my $self = shift;
7e2df1d9 31
58050177 32 unless ( $self->body ) {
33 $self->body( File::Temp->new );
34 }
aac7ca02 35
58050177 36 if ( my $length = length( $self->{buffer} ) ) {
9bbd91b6 37 $self->body->write( substr( $self->{buffer}, 0, $length, '' ), $length );
58050177 38 }
aac7ca02 39
58050177 40 if ( $self->length == $self->content_length ) {
41 seek( $self->body, 0, 0 );
7e2df1d9 42 $self->state('done');
58050177 43 }
44}
45
aac7ca02 46=back
47
48=head1 AUTHOR
49
50Christian Hansen, C<ch@ngmedia.com>
51
52=head1 LICENSE
53
54This library is free software . You can redistribute it and/or modify
55it under the same terms as perl itself.
56
57=cut
58
32b29b79 591;