Index: LayoutTests/http/tests/navigation/resources/save-beacon.php |
diff --git a/LayoutTests/http/tests/navigation/resources/save-beacon.php b/LayoutTests/http/tests/navigation/resources/save-beacon.php |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4de21933b06342f08ef3112b5617b9f776de0be1 |
--- /dev/null |
+++ b/LayoutTests/http/tests/navigation/resources/save-beacon.php |
@@ -0,0 +1,35 @@ |
+<?php |
+function prettify($name) { |
+ return str_replace(' ', '-', ucwords(str_replace('_', ' ', str_replace('http_', '', strtolower($name))))); |
+} |
+ |
+$beaconFilename = "beacon" . (isset($_REQUEST['name']) ? $_REQUEST['name'] : "") . ".txt"; |
+$beaconFile = fopen($beaconFilename . ".tmp", 'w'); |
+$httpHeaders = $_SERVER; |
+ksort($httpHeaders, SORT_STRING); |
+$contentType = ""; |
+foreach ($httpHeaders as $name => $value) { |
+ if ($name === "CONTENT_TYPE" || $name === "HTTP_REFERER" || $name === "REQUEST_METHOD" || $name === "HTTP_COOKIE" || $name === "HTTP_ORIGIN") { |
+ if ($name === "CONTENT_TYPE") { |
+ $contentType = $value; |
+ $value = preg_replace('/boundary=.*$/', '', $value); |
+ } |
+ $headerName = prettify($name); |
+ fwrite($beaconFile, "$headerName: $value\n"); |
+ } |
+} |
+$postdata = file_get_contents("php://input"); |
+if (strlen($postdata) == 0) |
+ $postdata = http_build_query($_POST); |
+ |
+fwrite($beaconFile, "Length: " . strlen($postdata) . "\n"); |
+if (strpos($contentType, "application/") !== false) { |
+ $postdata = base64_encode($postdata); |
+} |
+ |
+fwrite($beaconFile, "Body: $postdata\n"); |
+fclose($beaconFile); |
+rename($beaconFilename . ".tmp", $beaconFilename); |
+foreach ($_COOKIE as $name => $value) |
+ setcookie($name, "deleted", time() - 60, "/"); |
+?> |