The output of a CGI program must begin with a MIME header. MIME (Multipurpose Internet Mail Exchange) is a specification that was designed to add media type information to email messages on the Internet.
HTTP uses it to specify what type of data is being returned to the client.
Some common MIME types that you will see on the Web are:
An HTML document
A plain text document
A GIF image
A JPEG (or JPG) image
The HTTP specification states that all headers must be terminated with both a carriage-return (hex 0D) and a linefeed (hex 0A)
character (a CR/LF pair), and that the last header in a stream must be followed by a blank line, and also terminated with a
CR/LF pair. So, the MIME header at the beginning of a CGI program usually has two CR/LF pairs at the end of it.
The MIME header that is sent by the CGI program will actually be combined with a set of headers that the HTTP server will send to the client before sending the body of the data.