Created
June 4, 2018 15:53
-
-
Save yetibash/50c2eac9fa51beeea75f681630f6412d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub abtest_recv { | |
##################### | |
## SendToNews | |
##################### | |
if (req.url.path ~ "^/story/sports/mlb/(.*)/$") { | |
if (req.http.Cookie:abtest120) { | |
set req.http.X-AbVariant = req.http.Cookie:abtest120; | |
} else if (randombool(50,100)) { | |
set req.http.X-AbVariant = "120_s2n"; | |
} else { | |
set req.http.X-AbVariant = "120_gannett"; | |
} | |
if (req.http.X-AbVariant == "120_s2n") { | |
set req.http.X-articleVideoProvider = "s2n"; | |
} else if (req.http.X-AbVariant == "120_gannett") { | |
set req.http.X-articleVideoProvider = "gannett"; | |
} | |
} | |
} | |
sub abtest_fetch { | |
# Vary on X-AbVariant | |
if (beresp.http.Vary) { | |
set beresp.http.Vary = beresp.http.Vary ", X-AbVariant"; | |
} else { | |
set beresp.http.Vary = "X-AbVariant"; | |
} | |
# Vary on X-AltUrl | |
if (beresp.http.Vary) { | |
set beresp.http.Vary = beresp.http.Vary ", X-AltUrl"; | |
} else { | |
set beresp.http.Vary = "X-AltUrl"; | |
} | |
} | |
sub abtest_deliver { | |
##################### | |
## SendToNews | |
##################### | |
if (req.url.path ~ "^/story/sports/mlb/(.*)/$") { | |
if (!req.http.Cookie:abtest120) { | |
add resp.http.Set-Cookie = "abtest120=" req.http.X-AbVariant "; path=/; expires=" now + 180d ";"; | |
} | |
add resp.http.X-AbVariant = req.http.X-AbVariant; | |
add resp.http.X-articleVideoProvider = req.http.X-articleVideoProvider; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment