- 论坛徽章:
- 0
|
Object Headers
What does the "malformed header from script" error mean, and how can I
get rid of it?
This is the most frequent error new CGI programmers encounter.
It usually arises when the programmer writes a script that
returns some HTML when called -- in other words, a script that
generates a Web page on the fly.
"Header" refers to the HTTP object header lines in a server's
response to a client's request. The server sends several lines
of "metainformation" describing the content that will follow, a
blank line, and then the requested object. As with news and
mail, the header and the body are always separated by a blank
line.
CGI scripts that wish to return information to clients are
required to:
1. send a header line, Content-type:, describing with a MIME
Content-type the object that will follow (for instance, if
the script wanted to return HTML, this header would read,
"Content-type: text/html");
2. a blank line; and
3. the desired content.
A Perl script that generated HTML, then, would use the
following line to declare its Content-type:
print "Content-type: text/html\n\n";
The Content-type declaration must always be the first line sent
to standard output, if the script intends to return any
information to the client. |
|