httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Andersson" <rob...@profundis.nu>
Subject Re: [users@httpd] Premature end of script headers
Date Thu, 12 Jun 2003 04:09:30 GMT
In ancient times (April 26, 2003 ;-) Gabriel wrote:

> Hi,
>
> I'm tring to run my first CGI in C language. Of course it's Hello World.
> The code is that:
>
> #include <stdio.h>
>
> int main()
> {
> printf("Content-type: text/html\n\n");
> printf("<HTML>\n");
> printf("<BODY>\n");
> printf("<CENTER><H1>HELLO WORLD</H1></CENTER>\n");
> printf("</BODY>\n");
> printf("</HTML>");
>
> return 0;
> }
>
> when I try to run it the browser shows INTERNAL SERVER ERROR
> And the error log file shows Premature end of script headers

I doubt that Gabriel is still on this, but I saw no reply that commented on
what struck me first, so for the archives sake.

The problem is likely the new-lines. "\n" compiles to ASCII 10 = 0x0a. But,
the HTTP protocol defines new-line as <CRLF> => ASCII 13 + 10 = 0x0d + 0x0a.

Therefor, the first line should be:

    printf("Content-type: test/html\r\n\r\n");


Regards,
Robert Andersson


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message