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

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

Issue 2570473002: Enable the CORS preflight for sendBeacon()
Patch Set: Created 4 years 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
OLDNEW
1 <?php 1 <?php
2 require_once '../../resources/portabilityLayer.php'; 2 require_once '../../resources/portabilityLayer.php';
3 3
4 if ($_SERVER["REQUEST_METHOD"] == "OPTIONS") {
5 header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
6 header("Access-Control-Allow-Credentials: true");
7 header("Access-Control-Allow-Method: post");
8 header("Access-Control-Allow-Headers: content-type,cache-control");
9 exit();
10 }
11
4 function prettify($name) { 12 function prettify($name) {
5 return str_replace(' ', '-', ucwords(str_replace('_', ' ', str_replace('http_ ', '', strtolower($name))))); 13 return str_replace(' ', '-', ucwords(str_replace('_', ' ', str_replace('http_ ', '', strtolower($name)))));
6 } 14 }
7 15
8 $beaconFilename = sys_get_temp_dir() . "/beacon" . (isset($_REQUEST['name']) ? $ _REQUEST['name'] : "") . ".txt"; 16 $beaconFilename = sys_get_temp_dir() . "/beacon" . (isset($_REQUEST['name']) ? $ _REQUEST['name'] : "") . ".txt";
9 $beaconFile = fopen($beaconFilename . ".tmp", 'w'); 17 $beaconFile = fopen($beaconFilename . ".tmp", 'w');
10 $httpHeaders = $_SERVER; 18 $httpHeaders = $_SERVER;
11 ksort($httpHeaders, SORT_STRING); 19 ksort($httpHeaders, SORT_STRING);
12 $contentType = ""; 20 $contentType = "";
13 foreach ($httpHeaders as $name => $value) { 21 foreach ($httpHeaders as $name => $value) {
(...skipping 17 matching lines...) Expand all
31 39
32 fwrite($beaconFile, "Body: $postdata\n"); 40 fwrite($beaconFile, "Body: $postdata\n");
33 fclose($beaconFile); 41 fclose($beaconFile);
34 rename($beaconFilename . ".tmp", $beaconFilename); 42 rename($beaconFilename . ".tmp", $beaconFilename);
35 43
36 if (!array_key_exists('dontclearcookies', $_GET)) { 44 if (!array_key_exists('dontclearcookies', $_GET)) {
37 foreach ($_COOKIE as $name => $value) 45 foreach ($_COOKIE as $name => $value)
38 setcookie($name, "deleted", time() - 60, "/"); 46 setcookie($name, "deleted", time() - 60, "/");
39 } 47 }
40 ?> 48 ?>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698