Updated Branches: refs/heads/master 9a1fab382 -> 705b48ed4
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/705b48ed Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/705b48ed Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/705b48ed Branch: refs/heads/master Commit: 705b48ed450df2f74242cb63ea4b14839573df70 Parents: 9a1fab3 Author: Alan M. Carroll <[email protected]> Authored: Wed May 30 18:12:44 2012 -0500 Committer: Alan M. Carroll <[email protected]> Committed: Wed May 30 18:12:44 2012 -0500 ---------------------------------------------------------------------- proxy/hdrs/URL.cc | 28 ++++++++++++++++++++++++++-- 1 files changed, 26 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/705b48ed/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; }
