in reply to How to only download first 200 bytes of an image ?

from WWW::Anonymouse:
sub _ua_content_cb { my ($data, $res, $proto) = @_; $res->add_content(\$data); # Abort the request if enough content is received to parse for sta +tus. die if length $res->content > MAX_BYTES; } my $res = $self->{ua}->post( $self->_url, \%fields, Referer => $self->_referer, ':read_size_hint' => MAX_BYTES, ':content_cb' => \&_ua_content +_cb, );