Updated Branches:
  refs/heads/master 69bd54736 -> 4dd567102

TS-1322: CONNECT to parent proxy has URL with a trailing slash

I want to redirect a CONNECT request to parent proxy.  I'm doing
it with the TSHttpTxnParentProxySet API.  The problem is that the
URL that the TS is setting is invalid:

  CONNECT www.example.com:443/ HTTP/1.1
  Host: www.example.com:443

The TS adding to every URL a trailing slash in the end of the URL,
but here it makes the URL invalid (look at
http://www.ietf.org/rfc/rfc2817.txt in section 5.2).

I'm suggesting a patch for the URL.cc file that doesn't add a
trailing slash when not needed (when there is only hostname).  This
is valid action as is written in the RFC
(http://tools.ietf.org/html/rfc3986 in section 3) : "When authority
is present, the path must either be empty or begin with a slash
("/") character" While" authority" is the hostaname.


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

Branch: refs/heads/master
Commit: 4dd567102f8ead628da636920e543ac270f6d229
Parents: 69bd547
Author: Yakov Kopel <[email protected]>
Authored: Sat Jul 21 17:28:12 2012 -0700
Committer: James Peach <[email protected]>
Committed: Sat Jul 21 17:28:12 2012 -0700

----------------------------------------------------------------------
 CHANGES            |    3 +++
 proxy/hdrs/HTTP.cc |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4dd56710/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index da628d0..9c8129d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache Traffic Server 3.3.0
+  *) [TS-1322] CONNECT to parent proxy has URL with a trailing slash
+    Author: Yakov Kopel
+
   *) [TS-1370] Restore original stale-wile-revalidate code for posterity
     Author: Phil Sorber
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4dd56710/proxy/hdrs/HTTP.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index 5b3d0ed..eeec4e3 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -445,6 +445,9 @@ http_hdr_print(HdrHeap *heap, HTTPHdrImpl *hdr, char *buf, 
int bufsize, int *buf
       if (hdr->u.req.m_url_impl) {
         TRY(url_print(hdr->u.req.m_url_impl, buf, bufsize, bufindex, 
dumpoffset));
         if (bufsize - *bufindex >= 1) {
+          if (hdr->u.req.m_method_wks_idx == HTTP_WKSIDX_CONNECT) {
+              *bufindex -= 1; // remove trailing slash for CONNECT request
+          }
           p = buf + *bufindex;
           *p++ = ' ';
           *bufindex += 1;

Reply via email to