David
Fri May 27 22:57:27 CDT 2005
Sorry, but I do not think that makes sense.
Code run as CGI from a web server is supposed to output a valid HTTP
Response as according to RFC2616. This means that it should have:
1. HTTP Status Line -- looks like: HTTP/1.1 200 OK\r\n
2. Response headers, at minimum:
Content-Type: text/html\r\n
and either
Content-Length:\r\n
or
Transfer-Encoding: chunked\r\n
3. Double CRLF signifying the end of the response headers
4. Entity Body that matches Content-Length or Chunked encoding.
Your "couple of blank lines" introduces #3, double CRLF, into the response
output, which many browsers use to detect the response headers vs. response
entity-body. However, the rest of the CGI is pretty much invalid.
So, basically, your CGI is broken. It fails to:
1. output the HTTP status line
2. output Content-Length or Transfer-Encoding: chunked
3. Inserts a bogus header "<html><head><title></title></head>" (this is
considered response header because it is prior to the double CRLF)
Without the Content-Length or Transfer-Encoding: chunked, the browser has no
idea how much data constitutes the response, and without the double CRLF, it
won't know where the response headers are.
Your example basically relies on browser parsing routine to have your CGI be
displayed properly. Try putting the double writelin AFTER
writeln('</body></html>'); -- the browser probably won't even display
"Test successful" at this point.
--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//
"x-ray" <xray@discussions.microsoft.com> wrote in message
news:7AB40778-141D-4461-9544-D4798A04883B@microsoft.com...
a bit more information i forgot to include:
#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2005-05-27 21:02:53
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port
cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status
2005-05-27 21:02:53 127.0.0.1 GET /private-cgi-bin/cgidoctordummy.exe - 80 -
127.0.0.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322) 502 2
2147500037
2005-05-27 21:02:53 127.0.0.1 GET /private-cgi-bin/cgidoctordummy.exe - 80 -
127.0.0.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322) 502 2
2147500037
2005-05-27 21:04:00 127.0.0.1 GET /private-cgi-bin/cgidoctordummy.exe - 80 -
127.0.0.1
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2;+.NET+CLR+1.1.4322) 502 2
2147500037
"x-ray" wrote:
> i have a "hello world" application that ran fine under XP and 2000 but now
i
> am setting up to run on 2003.
>
> program CGIDoctorDummy;
> {$APPTYPE CONSOLE}
> begin
> Writeln('Content-type: text/html');
> writeln('<html><head><title></title></head>');
> writeln;
> writeln;
> writeln('<body>');
> writeln('<br>Test successful<br>');
> writeln('</body></html>');
> end.
>
> CGI Error
> The specified CGI application misbehaved by not returning a complete set
of
> HTTP headers.
>
> the app runs fine if i run it from a command prompt. but as soon as i run
it:
>
>
http://localhost/private-cgi-bin/cgidoctordummy.exe
>
> i get the error shown above.
>
> what am i doing wrong?
>
> thanks,
> mp