in reply to Re^2: HTTP headers and redirection
in thread HTTP headers and redirection

Let me explain in short words. An HTTP transaction consists of two parts. The first part is the headers, that consist of special data to tell the client how to interpret the data. The second part is the body. Headers are series of name-value pairs seperated by new lines. The header section as a whole is ended by an empty new line. So for example:
print "Content-type: text/html\n"; print "Location: foo\n\n"; print "This is the body"
You print two headers: Content-type, and location, then you send "this is the body" as the body of the message. However, if you do this:
print "Content-type: text/html\n\n"; print "Location: foo\n"; print "This is the body"
You are only sending one header, the Content-type. The Location: foo line and the "this is the body" is all interpreter as part of the body of the response.