This file documents the revision history for Perl extension HTTP::Body.
-0.7 2007-03-23 10:00:00
+0.7
+ - Some browsers such as MSIE send extra data after the body content. We now
+ properly ignore anything beyond Content-Length.
- Fixed parsing an empty (zero-length) file using multipart.
http://rt.cpan.org/NoAuth/Bug.html?id=25392
sub add {
my $self = shift;
+
+ my $cl = $self->content_length;
if ( defined $_[0] ) {
- $self->{buffer} .= $_[0];
$self->{length} += length( $_[0] );
+
+ # Don't allow buffer data to exceed content-length
+ if ( $self->{length} > $cl ) {
+ $_[0] = substr $_[0], 0, $cl - $self->{length};
+ $self->{length} = $cl;
+ }
+
+ $self->{buffer} .= $_[0];
}
unless ( $self->state eq 'done' ) {
$self->spin;
}
- return ( $self->length - $self->content_length );
+ return ( $self->length - $cl );
}
=item body
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 10;
use Cwd;
use HTTP::Body;
my $path = catdir( getcwd(), 't', 'data', 'urlencoded' );
-for ( my $i = 1; $i <= 1; $i++ ) {
+for ( my $i = 1; $i <= 2; $i++ ) {
my $test = sprintf( "%.3d", $i );
my $headers = YAML::LoadFile( catfile( $path, "$test-headers.yml" ) );
--- /dev/null
+one=foo&two=bar\r
--- /dev/null
+---
+Content-Length: 15
+Content-Type: application/x-www-form-urlencoded
+User-Agent: 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'
--- /dev/null
+---
+body: ~
+param:
+ one: foo
+ two: bar
+upload: {}