mkHun mkHun - 11 months ago 36
Perl Question

Why do 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
it will not execute. But, inside the HTML body, we do not use
can't make any sense, for new line we use

is necessary in the header line?


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.