Discussion:
Linux Apache & CGI (Bad Header problem. Why?)
(too old to reply)
Edu
2007-04-25 16:25:16 UTC
Permalink
Hi,

I was trying a CGI built with C in Apache2.Firstly, I forgot the
Content-type header and got the error (in apache's error.log):

malformed header from script. Bad header=<html>

Then I modified the code, adding the Content-type line:

printf("Content-type: text/html\n\n");
printf("<html>\n");
printf(" <HEAD>\n");
(...)

compiled, replaced the binary...and I still got:
malformed header from script. Bad header=<html>

I also tried to restart the server, but it was the same.

What's wrong?
Robert Harris
2007-04-25 18:21:27 UTC
Permalink
Post by Edu
Hi,
I was trying a CGI built with C in Apache2.Firstly, I forgot the
malformed header from script. Bad header=<html>
printf("Content-type: text/html\n\n");
printf("<html>\n");
printf(" <HEAD>\n");
(...)
malformed header from script. Bad header=<html>
I also tried to restart the server, but it was the same.
What's wrong?
You need a proper HTTP header. HTTP version 1.1 (the current version) is
defined by RFC2817; you can read it at:
<http://www.ietf.org/rfc/rfc2817.txt>

Note specifically that header lines should end with "\r\n".

Some versions of web servers will allow you to get away with headers of
varying degrees of badness. Some won't.

Robert

Loading...