[
https://issues.apache.org/jira/browse/TS-4395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15357805#comment-15357805
]
ASF GitHub Bot commented on TS-4395:
------------------------------------
Github user zwoop commented on a diff in the pull request:
https://github.com/apache/trafficserver/pull/747#discussion_r69205590
--- Diff: plugins/experimental/remap_purge/remap_purge.c ---
@@ -202,34 +202,38 @@ handle_purge(TSHttpTxn txnp, PurgeInstance *purge)
bool should_purge = false;
if (TS_SUCCESS == TSHttpTxnClientReqGet(txnp, &reqp, &hdr_loc)) {
- /* First see if we require the "secret" to be passed in a header, and
then use that */
- if (purge->header) {
- TSMLoc field_loc = TSMimeHdrFieldFind(reqp, hdr_loc, purge->header,
purge->header_len);
-
- if (field_loc) {
- const char *header;
- int header_len;
-
- header = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc,
-1, &header_len);
- TSDebug(PLUGIN_NAME, "Checking for %.*s == %s ?", header_len,
header, purge->secret);
- if (header && (header_len == purge->secret_len) && !memcmp(header,
purge->secret, header_len)) {
- should_purge = true;
+ int method_len = 0;
+ const char *method = TSHttpHdrMethodGet(reqp, hdr_loc, &method_len);
+
+ if ((TS_HTTP_METHOD_PURGE == method) || ((TS_HTTP_METHOD_GET ==
method) && purge->allow_get)) {
+ /* First see if we require the "secret" to be passed in a header,
and then use that */
+ if (purge->header) {
+ TSMLoc field_loc = TSMimeHdrFieldFind(reqp, hdr_loc,
purge->header, purge->header_len);
+
+ if (field_loc) {
+ const char *header;
+ int header_len;
+
+ header = TSMimeHdrFieldValueStringGet(reqp, hdr_loc, field_loc,
-1, &header_len);
+ TSDebug(PLUGIN_NAME, "Checking for %.*s == %s ?", header_len,
header, purge->secret);
+ if (header && (header_len == purge->secret_len) &&
!memcmp(header, purge->secret, header_len)) {
+ should_purge = true;
+ }
+ TSHandleMLocRelease(reqp, hdr_loc, field_loc);
}
- TSHandleMLocRelease(reqp, hdr_loc, field_loc);
- }
- } else {
- /* We are matching on the path component instead of a header */
- if (TS_SUCCESS == TSHttpHdrUrlGet(reqp, hdr_loc, &url_loc)) {
- int path_len = 0, method_len = 0;
- const char *path = TSUrlPathGet(reqp, url_loc, &path_len);
- const char *method = TSHttpHdrMethodGet(reqp, hdr_loc,
&method_len);
-
- TSDebug(PLUGIN_NAME, "Checking PATH = %.*s", path_len, path);
- if (((TS_HTTP_METHOD_PURGE == method) || ((TS_HTTP_METHOD_GET ==
method) && purge->allow_get)) && path &&
- (path_len >= purge->secret_len) && !memcmp(path + (path_len -
purge->secret_len), purge->secret, purge->secret_len)) {
- should_purge = true;
+ } else {
+ /* We are matching on the path component instead of a header */
+ if (TS_SUCCESS == TSHttpHdrUrlGet(reqp, hdr_loc, &url_loc)) {
+ int path_len = 0;
+ const char *path = TSUrlPathGet(reqp, url_loc, &path_len);
+
+ TSDebug(PLUGIN_NAME, "Checking PATH = %.*s", path_len, path);
+ if (path && (path_len >= purge->secret_len) &&
+ !memcmp(path + (path_len - purge->secret_len),
purge->secret, purge->secret_len)) {
--- End diff --
Don't think that would work, then you couldn't use this to purge a remap
rule like
map http://example.com http://real.example.com
At least not without modifying the path, or, taking that into account (i.e.
a separate case for this situation). Is it really worth that complexity? I sort
of envisioned people to pick pretty strong secrets here, e.g. genuuid.
> remap_purge: Simple plugin to purge an entire remap rule
> --------------------------------------------------------
>
> Key: TS-4395
> URL: https://issues.apache.org/jira/browse/TS-4395
> Project: Traffic Server
> Issue Type: New Feature
> Components: Plugins
> Reporter: Leif Hedstrom
> Assignee: Leif Hedstrom
> Fix For: 7.0.0
>
>
> This is similar to the existing plugin to purge based on a genID stored in a
> persistent storage. The difference is that the purging is done exclusively
> via a restful API, and has little (no) overhead on performance (since the
> generation ID is always in memory).
> Example:
> {code}
> map http://example.com/p1 http://p1.example.com
> @plugin=remap_purge.so @pparam=--path=__secret_purge__
> @pparam=--state=example_p1
> {code}
> And to purge:
> {code}
> $ curl -s -D - -X PURGE http://example.com/p1/__secret_purge__
> HTTP/1.1 200 OK
> Date: Sat, 30 Apr 2016 00:09:34 GMT
> Connection: close
> Server: ATS/7.0.0
> Content-Length: 39
> Content-Type: text/html
> PURGED http://example.com/p1
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)