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.google.com:443/ HTTP/1.1 Host: www.google.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). Solution: 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. The patch: diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc index 33416b5..f18ad0f 100644 --- a/proxy/hdrs/URL.cc +++ b/proxy/hdrs/URL.cc @@ -778,7 +778,7 @@ url_length_get(URLImpl * url) if (url->m_ptr_path) length += url->m_len_path + 1; // +1 for / - else + else if (!url->m_ptr_host) // we put '/' only when there is no host name length += 1; // +1 for / if (url->m_ptr_params) @@ -1551,8 +1551,12 @@ url_print(URLImpl * url, char *buf_start, int buf_length, int *buf_index_inout, buf_start, buf_length, buf_index_inout, buf_chars_to_skip_inout)); } } - - TRY(mime_mem_print("/", 1, buf_start, buf_length, buf_index_inout, buf_chars_to_skip_inout)); + + // Put the trailing slash only if there is another content in the url (path) + // or that there is no host name + if (url->m_ptr_path || !url->m_ptr_host) { + TRY(mime_mem_print("/", 1, buf_start, buf_length, buf_index_inout, buf_chars_to_skip_inout)); + } if (url->m_ptr_path) { TRY(mime_mem_print(url->m_ptr_path, url->m_len_path, buf_start, Protected by Websense Hosted Email Security -- www.websense.com