| Cgi.exe with MFC or not ? I wrote a simple cgi.exe program that returns a buffer to the client that POSTed the request. If I'm using plain C/C++, everything is OK. But if I start using MFC classes, after a while, I get the infamous message : The specified CGI application misbehaved by not returning a complete set of HTTP headers. and the IIS server logs the error 502.2. Is there any problem using MFC with an .exe ? If I use ISAPI, I don't have the problem. IIS is 6.0 and the OS is Win2003 server. The Cgi code is ///////////////////////////////// // ADD the statement CString AString ; AND YOU'LL GET AN ERROR 502.2 FROM IIS // // The specified CGI application misbehaved by not returning a complete set of HTTP headers. // CString AString ; //////////////////////////////////////////////////////////////////////////// / void main(int argc, char * argv[]) { BYTE Buf[256] ; for (int i = 0 ; i < 256 ; i++) { Buf[i] = (BYTE)i ; } _setmode (_fileno(stdout), _O_BINARY); printf ("Content-Length: %u\r\n",sizeof (Buf)) ; printf ("Content-type: application/octet-stream\r\n\r\n") ; fwrite (Buf , 1 , sizeof (Buf), stdout) ; } |