Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: LayoutTests/http/tests/navigation/resources/save-beacon.php

Issue 286063003: Save ping+beacon test status in temporary directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/http/tests/navigation/resources/save-Ping.php ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <?php 1 <?php
2 require_once '../../resources/portabilityLayer.php';
3
2 function prettify($name) { 4 function prettify($name) {
3 return str_replace(' ', '-', ucwords(str_replace('_', ' ', str_replace('http_ ', '', strtolower($name))))); 5 return str_replace(' ', '-', ucwords(str_replace('_', ' ', str_replace('http_ ', '', strtolower($name)))));
4 } 6 }
5 7
6 $beaconFilename = "beacon" . (isset($_REQUEST['name']) ? $_REQUEST['name'] : "") . ".txt"; 8 $beaconFilename = sys_get_temp_dir() . "/beacon" . (isset($_REQUEST['name']) ? $ _REQUEST['name'] : "") . ".txt";
7 $beaconFile = fopen($beaconFilename . ".tmp", 'w'); 9 $beaconFile = fopen($beaconFilename . ".tmp", 'w');
8 $httpHeaders = $_SERVER; 10 $httpHeaders = $_SERVER;
9 ksort($httpHeaders, SORT_STRING); 11 ksort($httpHeaders, SORT_STRING);
10 $contentType = ""; 12 $contentType = "";
11 foreach ($httpHeaders as $name => $value) { 13 foreach ($httpHeaders as $name => $value) {
12 if ($name === "CONTENT_TYPE" || $name === "HTTP_REFERER" || $name === "REQUE ST_METHOD" || $name === "HTTP_COOKIE" || $name === "HTTP_ORIGIN") { 14 if ($name === "CONTENT_TYPE" || $name === "HTTP_REFERER" || $name === "REQUE ST_METHOD" || $name === "HTTP_COOKIE" || $name === "HTTP_ORIGIN") {
13 if ($name === "CONTENT_TYPE") { 15 if ($name === "CONTENT_TYPE") {
14 $contentType = $value; 16 $contentType = $value;
15 $value = preg_replace('/boundary=.*$/', '', $value); 17 $value = preg_replace('/boundary=.*$/', '', $value);
16 } 18 }
17 $headerName = prettify($name); 19 $headerName = prettify($name);
18 fwrite($beaconFile, "$headerName: $value\n"); 20 fwrite($beaconFile, "$headerName: $value\n");
19 } 21 }
20 } 22 }
21 $postdata = file_get_contents("php://input"); 23 $postdata = file_get_contents("php://input");
22 if (strlen($postdata) == 0) 24 if (strlen($postdata) == 0)
23 $postdata = http_build_query($_POST); 25 $postdata = http_build_query($_POST);
24 26
25 fwrite($beaconFile, "Length: " . strlen($postdata) . "\n"); 27 fwrite($beaconFile, "Length: " . strlen($postdata) . "\n");
26 if (strpos($contentType, "application/") !== false) { 28 if (strpos($contentType, "application/") !== false) {
27 $postdata = base64_encode($postdata); 29 $postdata = base64_encode($postdata);
28 } 30 }
29 31
30 fwrite($beaconFile, "Body: $postdata\n"); 32 fwrite($beaconFile, "Body: $postdata\n");
31 fclose($beaconFile); 33 fclose($beaconFile);
32 rename($beaconFilename . ".tmp", $beaconFilename); 34 rename($beaconFilename . ".tmp", $beaconFilename);
33 foreach ($_COOKIE as $name => $value) 35 foreach ($_COOKIE as $name => $value)
34 setcookie($name, "deleted", time() - 60, "/"); 36 setcookie($name, "deleted", time() - 60, "/");
35 ?> 37 ?>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/navigation/resources/save-Ping.php ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698