in reply to Reading RAW POST data
in thread How do I read POST data that is not encoded, and was submitted without a parameter name
AFAIK read only tries to read specified amount of data from filehandle and actually can return less data. Correct code should use loop like:
sub _read_content { my $length = $ENV{CONTENT_LENGTH}; my $rest = $length; my $buf; while($rest < $length) { my $read = read STDIN, $buf, $length - $rest, $rest; die "Can't read from a stream: $!" unless defined $read; return $buf if $read == 0; $rest += $read; } return $buf; }
--
Ilya Martynov
(http://martynov.org/)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re:x2 Reading RAW POST data
by grinder (Bishop) on Dec 16, 2001 at 20:23 UTC | |
by IlyaM (Parson) on Dec 18, 2001 at 15:35 UTC | |
by IlyaM (Parson) on Dec 17, 2001 at 01:42 UTC |
In Section
Seekers of Perl Wisdom