trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject git commit: TS-2179 Added option for lowercase path
Date Wed, 04 Sep 2013 22:52:32 GMT
Updated Branches:
  refs/heads/master 182405352 -> ebe3502c1


TS-2179 Added option for lowercase path


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/ebe3502c
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/ebe3502c
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/ebe3502c

Branch: refs/heads/master
Commit: ebe3502c18362ac013845b0f197c09227bc03ef9
Parents: 1824053
Author: Bryan Call <bcall@apache.org>
Authored: Wed Sep 4 15:51:58 2013 -0700
Committer: Bryan Call <bcall@apache.org>
Committed: Wed Sep 4 15:51:58 2013 -0700

----------------------------------------------------------------------
 plugins/regex_remap/README         |  1 +
 plugins/regex_remap/regex_remap.cc | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ebe3502c/plugins/regex_remap/README
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/README b/plugins/regex_remap/README
index f3dad4e..d2e0c3c 100644
--- a/plugins/regex_remap/README
+++ b/plugins/regex_remap/README
@@ -90,6 +90,7 @@ on the right hand side:
     $p     - The original port number
     $s     - The scheme (e.g. http) of the request
     $P     - The entire path of the request
+    $l     - The entire path of the request in lowercase
     $q     - The query part of the request
     $r     - The path parameters of the request (not implemented yet)
     $c     - The cookie string from the request

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ebe3502c/plugins/regex_remap/regex_remap.cc
----------------------------------------------------------------------
diff --git a/plugins/regex_remap/regex_remap.cc b/plugins/regex_remap/regex_remap.cc
index 8b637f6..13955a1 100644
--- a/plugins/regex_remap/regex_remap.cc
+++ b/plugins/regex_remap/regex_remap.cc
@@ -41,6 +41,7 @@
 #include <iostream>
 #include <fstream>
 #include <string>
+#include <ctype.h>
 
 // Get some specific stuff from libts, yes, we can do that now that we build inside the core.
 #include "ink_platform.h"
@@ -67,6 +68,7 @@ enum ExtraSubstitutions {
   SUB_QUERY = 17,
   SUB_MATRIX = 18,
   SUB_CLIENT_IP = 19,
+  SUB_LOWER_PATH = 20,
 };
 
 
@@ -264,6 +266,9 @@ class RemapRegex
           case 'P':
             ix = SUB_PATH;
             break;
+          case 'l':
+            ix = SUB_LOWER_PATH;
+            break;
           case 'q':
             ix = SUB_QUERY;
             break;
@@ -348,6 +353,7 @@ class RemapRegex
           len += req_url->scheme_len;
           break;
         case SUB_PATH:
+        case SUB_LOWER_PATH:
           len += req_url->path_len;
           break;
         case SUB_QUERY:
@@ -411,6 +417,7 @@ class RemapRegex
             len = req_url->scheme_len;
             break;
           case SUB_PATH:
+          case SUB_LOWER_PATH:
             str = req_url->path;
             len = req_url->path_len;
             break;
@@ -434,7 +441,17 @@ class RemapRegex
           // If one of the rules fetched a read-only string, copy it in.
           if (str && len > 0) {
             memcpy(p1, str, len);
-            p1 += len;
+            if (ix == SUB_LOWER_PATH) {
+              TSDebug(PLUGIN_NAME, "lowercasing url: %.*s", len, str);
+              char *end = p1 + len;
+              while (p1 <= end) {
+                *p1 = tolower(*p1);
+                p1++;
+              }
+              p1 = end;
+            } else {
+              p1 += len;
+            }
           }
         }
         p2 += (_sub_pos[i] - prev + 2);


Mime
View raw message