Okay, in a CGI application running in IIS 4.0 I am doing the following:
- Getting the standard output handle.
- SetConsoleMode(hOut, 0) to prevent "cooking" the binary data
- Sending the header "Content-type: image/jpeg\n" and "Content-length: 1841\n\n"
- Using WriteFile to send the file data
The JPEG file I am sending is 1841 bytes long. When I send exactly 1841 bytes using WriteFile I get an error that not all data has been sent. When I append an extra nul to the 1841 bytes, I get an "invalid image file" error.
Does anyone have any simple code for sending a binary file from a CGI application in IIS 4.0?