You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/09/10 17:09:33 UTC

[07/48] git commit: TS-2179 Added option for lowercase path

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/5.0.x
Commit: ebe3502c18362ac013845b0f197c09227bc03ef9
Parents: 1824053
Author: Bryan Call <bc...@apache.org>
Authored: Wed Sep 4 15:51:58 2013 -0700
Committer: Bryan Call <bc...@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);