chromium/third_party/blink/web_tests/http/tests/navigation/resources/form-target.pl

#!/usr/bin/perl
# Simple script to that dumps the HTTP request method and all input parameters.

use CGI;
$query = new CGI;

print "Content-type: text/html\r\n";
print "\r\n";

$method = $query->request_method();

print <<HEADER;
<body>
<p>This page was requested with the HTTP method $method.</p>

<p>Parameters:</p>
<ul>
HEADER

@paramNames = $query->param;

foreach $paramName (@paramNames)
{
    print "<li>" . $paramName . " = " . $query->param($paramName) . "</li>"
}

print <<HEADER2;
</ul>
<p>Http headers:</p>
<ul>
HEADER2

my %headers = map { $_ => $query->http($_) } $query->http();
for my $header ( sort (keys %headers) ) {
    if (("$header" ne "HTTP_ACCEPT_ENCODING") &&
        ("$header" ne "HTTP_ACCEPT_LANGUAGE") &&
        ("$header" ne "HTTP_ACCEPT") &&
        ("$header" ne "HTTP_USER_AGENT")) {
        print "<li>$header = $headers{$header}</li>\n";
    }
}

print <<FOOTER
</ul>
<script>
var isDone = true;
if (sessionStorage.formTargetShouldNavAndGoBack) {
  if (sessionStorage.didNav) {
      delete sessionStorage.didNav;
      delete sessionStorage.formTargetShouldNavAndGoBack;
  } else {
      isDone = false;
      sessionStorage.didNav = true;
      onload = function() {
          setTimeout(function() {window.location.href = 'go-back.html'}, 0);
      };
  }
}

if (sessionStorage.topShouldNavAndGoBack) {
  if (!sessionStorage.didNav) {
      isDone = false;
      sessionStorage.didNav = true;
      onload = function() {
          setTimeout(function() {top.location.href = 'go-back.html'}, 0);
      };
  }
}

if (isDone && window.testRunner)
    testRunner.notifyDone();

</script>
</body>
FOOTER