in reply to Re: Re: Re: Re: Re: Re: Re: Re: using CGI on HTTP::Request from HTTP::Daemon
in thread using CGI on HTTP::Request from HTTP::Daemon
No that's the whole point of the sample code. Try to read() CONTENT_LENGTH bytes - it will hang as read() is never returning 0/undef but is just blocking.
The only way I found to make it work was to use this:
if ( $length ) { print "Expecting $length bytes\n"; while ( length($data) < $length ) { last unless sysread( STDIN, $buf, 16 ); print "Got: $buf\n"; $data .= $buf; } }
If you use a standard read() it will hang (buffered) but sysread bypasses the buffering and it works as expected. The length check effectively avoids the last read where even for sysread it will block if there is no data left.
I will hack it into shape when I get a moment. It is good to have a failure test case in such a small portable package.....
cheers
tachyon
|
|---|