Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InitialOrigin will be used to pair the setCookie with the eventual non-redirect host #1981

Merged
merged 3 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions www/experiments.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@
// initial host is used by a few opps, so we'll calculate it here
$initialHost = null;
$rootURL = null;
$initialOrigin = null;
foreach ($requests as $request) {
if ($request['is_base_page'] == "true") {
$initialHost = $request['host'];
$rootURL = trim($request['full_url']);
$initialOrigin = "http" . (strpos( $rootURL, "https") === 0 ? "s" : "" ) . "://" . $initialHost;
break;
}
}
Expand Down Expand Up @@ -178,6 +180,7 @@

// this is to capture the first host that is a successful response and not a redirect. that'll be the one we want to override in an experiment
echo '<input type="hidden" name="initialHostNonRedirect" value="'. $initialHost .'">';
echo '<input type="hidden" name="initialOriginNonRedirect" value="'. $initialOrigin .'">';

// used for tracking exp access
$expCounter = 0;
Expand Down
3 changes: 2 additions & 1 deletion www/runtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ function buildSelfHost($hosts){
} else {
// the first non-redirect host is passed in from experiments
$hostToUse = isset( $req_initialHostNonRedirect ) ? $req_initialHostNonRedirect : '%HOST%';
$originToUse = isset( $req_initialOriginNonRedirect ) ? $req_initialOriginNonRedirect : '%ORIGIN%';
scottjehl marked this conversation as resolved.
Show resolved Hide resolved
$test['script'] = "overrideHost\t". $hostToUse ."\t$experimentURL\r\n";
$scriptNavigate = "navigate\t%URL%\r\n";
$test['script'] .= $scriptNavigate;
Expand Down Expand Up @@ -984,7 +985,7 @@ function buildSelfHost($hosts){


//replace last step with last step plus recipes
$test['script'] = str_replace($scriptNavigate, "setCookie\t%ORIGIN%\twpt-experiments=" . rawurlencode($recipeScript) . "\r\n" . $scriptNavigate, $test['script'] );
$test['script'] = str_replace($scriptNavigate, "setCookie\t". $originToUse ."\twpt-experiments=" . urlencode($recipeScript) . "\r\n" . $scriptNavigate, $test['script'] );


$id = CreateTest($test, $test['url']);
Expand Down