Next Previous Contents

2. Standard CGI (Perl)

The problem is similar to ISAPI - read exact ContentLength bytes and all works fine. I tested the following with about 2.5 MBytes at once per call without any additional buffer variable and it worked well:


binmode STDIN;
read(STDIN, $buf, $ENV{CONTENT_LENGTH});

Don't forget to set STDIN to binary mode, if you're in Windows. An EOF char causes a broken connection otherwise. If you write $buf to a file set the file handle to binary mode too.

Writing data to the STDOUT works in the same way and it is also recommended to use binmode for all handles if necessary.


Next Previous Contents