in reply to cgi response

I think you mean Content-type: text/html\n\n. Note that it has a hyphen. If you were to use the CGI module, you could simply use the header() method with no arguments:

use CGI ':standard'; print header();

You'll find you have more luck parsing params with CGI.pm than trying to read from INPUT which probably isn't even open.