Fixed buffer bug in HTTP::Body::OctetStream
[catagits/HTTP-Body.git] / lib / HTTP / Body.pm
index 5b3a0d1..13ae9c3 100644 (file)
@@ -3,9 +3,8 @@ package HTTP::Body;
 use strict;
 
 use Carp       qw[ ];
-use List::Util qw[ first ];
 
-our $VERSION = '0.2';
+our $VERSION = 0.6;
 
 our $TYPES = {
     'application/octet-stream'          => 'HTTP::Body::OctetStream',
@@ -13,6 +12,10 @@ our $TYPES = {
     'multipart/form-data'               => 'HTTP::Body::MultiPart'
 };
 
+require HTTP::Body::OctetStream;
+require HTTP::Body::UrlEncoded;
+require HTTP::Body::MultiPart;
+
 =head1 NAME
 
 HTTP::Body - HTTP Body Parser
@@ -66,7 +69,13 @@ sub new {
         Carp::croak( $class, '->new( $content_type, $content_length )' );
     }
 
-    my $type = first { index( lc($content_type), $_ ) >= 0 } keys %{$TYPES};
+    my $type;
+    foreach my $supported ( keys %{$TYPES} ) {
+        if ( index( lc($content_type), $supported ) >= 0 ) {
+            $type = $supported;
+        }
+    }
+
     my $body = $TYPES->{ $type || 'application/octet-stream' };
 
     eval "require $body";
@@ -93,7 +102,7 @@ sub new {
 
 =item add
 
-Add string to itnernal buffer. Will call spin unless done. returns
+Add string to internal buffer. Will call spin unless done. returns
 length before adding self.
 
 =cut
@@ -251,6 +260,10 @@ sub upload {
 
 =back
 
+=head1 BUGS
+
+Chunked requests are currently not supported.
+
 =head1 AUTHOR
 
 Christian Hansen, C<ch@ngmedia.com>