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 2012/05/31 07:32:59 UTC

[2/2] git commit: TS-1277: Parse the port from the URL on the remap path.

TS-1277: Parse the port from the URL on the remap path.


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

Branch: refs/heads/devrel/3.1.4
Commit: bb387b0d36fd6b016974693a76e8113ef8d7cb53
Parents: 73dcf37
Author: Alan M. Carroll <am...@network-geographics.com>
Authored: Wed May 30 18:12:44 2012 -0500
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Wed May 30 23:32:32 2012 -0600

----------------------------------------------------------------------
 proxy/hdrs/URL.cc |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/bb387b0d/proxy/hdrs/URL.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc
index af07543..33416b5 100644
--- a/proxy/hdrs/URL.cc
+++ b/proxy/hdrs/URL.cc
@@ -1465,12 +1465,36 @@ url_parse_http_no_path_component_breakdown(HdrHeap * heap,
   } else {
     host_end = cur = end;
   }
-  if (base != host_end)
+
+  // Did we find something for the host?
+  if (base != host_end) {
+    char const* port = 0;
+    int port_len = 0;
+
+    // Check for port. Search from the end stopping on the first non-digit
+    // or more than 5 digits and a delimiter.
+    port = host_end - 1;
+    char const* port_limit = host_end - 6;
+    if (port_limit < base) port_limit = base; // don't go past start.
+    while (port >= port_limit && isdigit(*port))
+      --port;
+    // A port if we're still in the host area and we found a ':' as
+    // the immediately preceeding character.
+    if (port >= base && ':' == *port) {
+      port_len = host_end - port - 1; // must compute this first.
+      host_end = port; // then point at colon.
+      ++port; // drop colon from port.
+      url_port_set(heap, url, port, port_len, copy_strings);
+    }
+    // Now we can set the host.
     url_host_set(heap, url, base, host_end - base, copy_strings);
+  }
 
   // path is anything that's left.
-  if (cur < end)
+  if (cur < end) {
     url_path_set(heap, url, cur, end - cur, copy_strings);
+    cur = end;
+  }
   *start = cur;
   return PARSE_DONE;
 }