Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion plugins/regex_remap/regex_remap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
const SrcUrl src_url([=]() -> SrcUrl {
SrcUrl u;

if (ri->pristine_url) {
if (!ri->pristine_url) {
u.bufp = rri->requestBufp;
u.loc = rri->requestUrl;
u.bad = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HTTP/1.1 301 Redirect
Location: http://localhost:SERVER_PORT/alpha/bravo/?action=newsfed;param0001=00003E;param0002=00004E;param0003=00005E
12 changes: 7 additions & 5 deletions tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@
ts.Disk.File(regex_remap_conf_path, typename="ats:config").AddLines([
"# regex_remap configuration\n"
"^/alpha/bravo/[?]((?!action=(newsfeed|calendar|contacts|notepad)).)*$ http://example.one @status=301\n"
"^/charlie http://example.one @status=301\n"
])

ts.Disk.remap_config.AddLine(
"map http://example.one/ http://localhost:{}/ @plugin=regex_remap.so @pparam=regex_remap.conf\n".format(server.Variables.Port)
)
ts.Disk.remap_config.AddLine(
"map http://example.two/charlie http://localhost:{}/delta ".format(server.Variables.Port) +
"map http://example.two/ http://localhost:{}/ ".format(server.Variables.Port) +
"@plugin=regex_remap.so @pparam=regex_remap.conf @pparam=pristine\n"
)

Expand All @@ -83,15 +82,18 @@
tr.Processes.Default.Streams.stdout = "gold/regex_remap_smoke.gold"
tr.StillRunningAfter = ts

# 1 Test - Match and redirect
tr = Test.AddTestRun("pristine test")
tr.Processes.Default.Command = (
curl_and_args + '--header "uuid: {}" http://example.two/charlie'.format(creq["headers"]["fields"][1][1])
curl_and_args +
"'http://example.two/alpha/bravo/?action=newsfed;param0001=00003E;param0002=00004E;param0003=00005E'" +
f" | grep -e '^HTTP/' -e '^Location' | sed 's/{server.Variables.Port}/SERVER_PORT/'"
)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stdout = "gold/regex_remap_smoke.gold"
tr.Processes.Default.Streams.stdout = "gold/regex_remap_redirect.gold"
tr.StillRunningAfter = ts

# Crash test.
# 2 Test - Crash test.
tr = Test.AddTestRun("crash test")
creq = replay_txns[1]['client-request']
tr.Processes.Default.Command = curl_and_args + \
Expand Down