I have a test webserver, i want to write a script to check what headers are being passed in the request and send back a 302 if all headers are present, but i also want to get the body of what was sent in the request and write it to a file - how do i do this? My code for checking headers;
#!/usr/bin/perl
$user_agent = $ENV{"HTTP_USER_AGENT"};
$accept = $ENV{"HTTP_ACCEPT"};
$accept_language = $ENV{"HTTP_ACCEPT_LANGUAGE"};
$content_disposition = $ENV{"HTTP_CONTENT_DISPOSITION"};
$content_type = $ENV{"HTTP_CONTENT_TYPE"};
$content_length = $ENV{"HTTP_CONTENT_LENGTH"};
$referer = $ENV{"HTTP_REFERER"};
%cookie = $ENV{"HTTP_COOKIE"};
if ($accept && $user_agent && $accept_language && $content_disposition &&
$content_type && $content_length && $referer && $cookie)
{
print "status: 302\n";
print "location: print "Content-type: text/plain\n";
print "\n";
print <<"EOM";
Go read the news
EOM
}
else
{
print "Status: 404 Not Found\n\n"
}
Help much appreciated. Thanks.
#!/usr/bin/perl
$user_agent = $ENV{"HTTP_USER_AGENT"};
$accept = $ENV{"HTTP_ACCEPT"};
$accept_language = $ENV{"HTTP_ACCEPT_LANGUAGE"};
$content_disposition = $ENV{"HTTP_CONTENT_DISPOSITION"};
$content_type = $ENV{"HTTP_CONTENT_TYPE"};
$content_length = $ENV{"HTTP_CONTENT_LENGTH"};
$referer = $ENV{"HTTP_REFERER"};
%cookie = $ENV{"HTTP_COOKIE"};
if ($accept && $user_agent && $accept_language && $content_disposition &&
$content_type && $content_length && $referer && $cookie)
{
print "status: 302\n";
print "location: print "Content-type: text/plain\n";
print "\n";
print <<"EOM";
Go read the news
EOM
}
else
{
print "Status: 404 Not Found\n\n"
}
Help much appreciated. Thanks.