1 package HTTP::Body::Compat;
7 use Params::Validate qw[];
8 use HTTP::Body::Context qw[];
11 my $class = ref $_[0] ? ref shift : shift;
12 my ( $content_type, $content_length ) = Params::Validate::validate_with(
16 type => Params::Validate::SCALAR,
20 type => Params::Validate::SCALAR,
24 called => "$class\::new"
27 my $context = HTTP::Body::Context->new(
29 'Content-Type' => $content_type,
30 'Content-Length' => $content_length
34 return bless( {}, $class )->initialize( { context => $context } );
40 if ( defined $_[0] ) {
41 $self->{length} += bytes::length $_[0];
46 if ( $self->length == $self->content_length ) {
51 return ( $self->length - $self->content_length );
55 return $_[0]->context->content;
63 return $_[0]->context->content_length;
67 return $_[0]->context->content_type;
71 return $_[0]->{length};
82 return $self->context->param->add(@_);
85 return scalar $self->context->param->as_hash;
92 return $self->context->upload->add(@_);
95 return scalar $self->context->upload->as_hash;