Changing default behavior of upload handling to stop taking over the upload extension...
[catagits/HTTP-Body.git] / lib / HTTP / Body / OctetStream.pm
1 package HTTP::Body::OctetStream;
2
3 use strict;
4 use base 'HTTP::Body';
5 use bytes;
6
7 use File::Temp 0.14;
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     my $self = shift;
31
32     unless ( $self->body ) {
33         $self->body( File::Temp->new( DIR => $self->tmpdir ) );
34     }
35
36     if ( my $length = length( $self->{buffer} ) ) {
37         $self->body->write( substr( $self->{buffer}, 0, $length, '' ), $length );
38     }
39
40     if ( $self->length == $self->content_length ) {
41         seek( $self->body, 0, 0 );
42         $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;