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
4 changes: 4 additions & 0 deletions doc/admin-guide/plugins/xdebug.en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ X-Remap
If the URL was remapped for a request, this header gives the *to* and *from* field from the line in remap.config that caused
the URL to be remapped.

X-Effective-URL
If the URL was remapped for a request, this header gives the URL resulting from the remapping. Note that if there are
multiple remaps, this header aggregates the URLs, space-comma-separated. The URLs are inside doublequotes.

X-ParentSelection-Key
The ``X-ParentSelection-Key`` header contains the URL that is used to
determine parent selection for an object in the Traffic Server. This
Expand Down
6 changes: 5 additions & 1 deletion plugins/xdebug/xdebug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,11 @@ InjectEffectiveURLHeader(TSHttpTxn txn, TSMBuffer buffer, TSMLoc hdr)
if (strval.ptr != nullptr && strval.len > 0) {
TSMLoc dst = FindOrMakeHdrField(buffer, hdr, "X-Effective-URL", lengthof("X-Effective-URL"));
if (dst != TS_NULL_MLOC) {
TSReleaseAssert(TSMimeHdrFieldValueStringInsert(buffer, hdr, dst, -1 /* idx */, strval.ptr, strval.len) == TS_SUCCESS);
char buf[16 * 1024];
int len = snprintf(buf, sizeof(buf), "\"%s\"", strval.ptr);
if (len == strval.len + 2 && len <= static_cast<int>(sizeof(buf)) - 1) { // Only copy back if len expected and within buffer.
TSReleaseAssert(TSMimeHdrFieldValueStringInsert(buffer, hdr, dst, -1 /* idx */, buf, len) == TS_SUCCESS);
}
TSHandleMLocRelease(buffer, hdr, dst);
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/gold_tests/pluginTest/xdebug/x_effective_url/four.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GET /argh,urgh HTTP/1.1
Host: four
X-Debug: X-effective-url
Connection: close

19 changes: 15 additions & 4 deletions tests/gold_tests/pluginTest/xdebug/x_effective_url/out.gold
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Server: ATS/``
Cache-Control: no-store
Content-Type: text/html
Content-Language: en
X-Effective-URL: http://none/argh
X-Effective-URL: "http://none/argh"
Content-Length: 391

<HTML>
Expand All @@ -32,7 +32,7 @@ Age: ``
Transfer-Encoding: chunked
Connection: close
Server: ATS/``
X-Effective-URL: http://127.0.0.1:SERVER_PORT/argh
X-Effective-URL: "http://127.0.0.1:SERVER_PORT/argh"

0

Expand All @@ -43,7 +43,7 @@ Age: ``
Transfer-Encoding: chunked
Connection: close
Server: ATS/``
X-Effective-URL: http://127.0.0.1:SERVER_PORT/two/argh
X-Effective-URL: "http://127.0.0.1:SERVER_PORT/two/argh"

0

Expand All @@ -54,7 +54,18 @@ Age: ``
Transfer-Encoding: chunked
Connection: close
Server: ATS/``
X-Effective-URL: http://127.0.0.1:SERVER_PORT/argh
X-Effective-URL: "http://127.0.0.1:SERVER_PORT/argh"

0

======
HTTP/1.1 200 OK
Date: ``
Age: ``
Transfer-Encoding: chunked
Connection: close
Server: ATS/``
X-Effective-URL: "http://127.0.0.1:SERVER_PORT/four/argh,urgh"

0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
"headers": "GET /two/argh HTTP/1.1\r\nHost: doesnotmatter\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
server.addResponse("sessionlog.json", request_header_two, response_header)

# request_header_three would be identical to request_header.

request_header_four = {
"headers": "GET /four/argh,urgh HTTP/1.1\r\nHost: doesnotmatter\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
server.addResponse("sessionlog.json", request_header_four, response_header)

ts = Test.MakeATSProcess("ts")

ts.Disk.records_config.update({
Expand All @@ -48,7 +54,10 @@
"map http://two http://127.0.0.1:{0}".format(server.Variables.Port) + "/two"
)
ts.Disk.remap_config.AddLine(
"regex_map http://three[0-9]+ http://127.0.0.1:{0}".format(server.Variables.Port)
"regex_map http://three[0-9]+ http://127.0.0.1:{0}".format(server.Variables.Port) # Host: three123
)
ts.Disk.remap_config.AddLine(
"regex_map http://four http://127.0.0.1:{0}".format(server.Variables.Port) + "/four"
)

tr = Test.AddTestRun()
Expand All @@ -73,6 +82,7 @@ def sendMsg(msgFile):
sendMsg('one')
sendMsg('two')
sendMsg('three')
sendMsg('four')

tr = Test.AddTestRun()
tr.Processes.Default.Command = "echo test out.gold"
Expand Down