mkHun mkHun - 4 months ago 9
Perl Question

Why use `\n` in CGI script while printing header?

In CGI script, on the top the program we use the:

print "Content-type: text/html\n\n";
without using
\n
it will not execute. But, inside the HTML body, we do not use
\n
because
\n
can't make any sense, for new line we use
<br>
tag.

Why
\n
is necessary in the header line?

Answer

Content-type: text/html is the HTTP header, not HTML. For detecting the end of HTTP header must be one empty line. First \n for end of current line, second \n for new empty line.

Comments