This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  6fd307f   TS-5047: Fix unmapped URL logging tags.
6fd307f is described below

commit 6fd307f02209f839accf79ad9171778528921f03
Author: Alan M. Carroll <[email protected]>
AuthorDate: Wed Nov 9 09:04:38 2016 -0600

    TS-5047: Fix unmapped URL logging tags.
---
 doc/admin-guide/logging/formatting.en.rst |  3 +--
 proxy/InkAPI.cc                           |  2 +-
 proxy/hdrs/URL.h                          |  2 +-
 proxy/http/HttpSM.cc                      | 22 +++++++++++++++++-----
 proxy/http/HttpTransact.h                 |  5 ++---
 proxy/http/remap/RemapProcessor.cc        |  2 +-
 proxy/logging/LogAccessHttp.cc            |  4 ++--
 7 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/doc/admin-guide/logging/formatting.en.rst 
b/doc/admin-guide/logging/formatting.en.rst
index 346db45..4fd1a4c 100644
--- a/doc/admin-guide/logging/formatting.en.rst
+++ b/doc/admin-guide/logging/formatting.en.rst
@@ -714,7 +714,7 @@ cquc  Client Request Canonical URL from the client request 
to |TS|. This field
                      percent-escaped entity codes).
 cqup  Proxy Request  Path component from the remapped client request.
 cqus  Client Request URL scheme from the client request.
-cquuc Client Request Canonical (prior to remapping) URL from client request.
+cquuc Client Request Canonical (prior to remapping) effective URL from client 
request.
 cquup Client Request Canonical (prior to remapping) path component from the
                      client request. Compare with cqup_.
 cquuh Client Request Unmapped URL host from the client request.
@@ -754,4 +754,3 @@ Some examples below ::
   '%<cqup[0:30]>' // the first 30 characters of <cqup>.
   '%<cqup[-10:]>' // the last 10 characters of <cqup>.
   '%<cqup[:-5]>'  // everything except the last 5 characters of <cqup>.
-
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 48697d5..1f8569e 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -4674,7 +4674,7 @@ TSHttpTxnPristineUrlGet(TSHttpTxn txnp, TSMBuffer *bufp, 
TSMLoc *url_loc)
 
   if (hptr->valid()) {
     *(reinterpret_cast<HTTPHdr **>(bufp)) = hptr;
-    *url_loc                              = 
(TSMLoc)sm->t_state.pristine_url.m_url_impl;
+    *url_loc                              = 
(TSMLoc)sm->t_state.unmapped_url.m_url_impl;
 
     if (sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS) {
       if (*url_loc == nullptr) {
diff --git a/proxy/hdrs/URL.h b/proxy/hdrs/URL.h
index 2ef3d01..0b94f9e 100644
--- a/proxy/hdrs/URL.h
+++ b/proxy/hdrs/URL.h
@@ -333,7 +333,7 @@ private:
 /*-------------------------------------------------------------------------
   -------------------------------------------------------------------------*/
 
-inline URL::URL() : m_url_impl(NULL)
+inline URL::URL() : m_url_impl(nullptr)
 {
 }
 
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index f2638d0..046810b 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -4024,11 +4024,23 @@ HttpSM::do_remap_request(bool run_inline)
     ret = remapProcessor.setup_for_remap(&t_state);
   }
 
-  // Preserve pristine url before remap
-  // This needs to be done after the Host: header for reverse proxy is added 
to the url, but
-  // before we return from this function for forward proxy
-  
t_state.pristine_url.create(t_state.hdr_info.client_request.url_get()->m_heap);
-  t_state.pristine_url.copy(t_state.hdr_info.client_request.url_get());
+  // Preserve effective url before remap
+  
t_state.unmapped_url.create(t_state.hdr_info.client_request.url_get()->m_heap);
+  t_state.unmapped_url.copy(t_state.hdr_info.client_request.url_get());
+  // Depending on a variety of factors the HOST field may or may not have been 
promoted to the
+  // client request URL. The unmapped URL should always have that promotion 
done. If the HOST field
+  // is not already there, promote it only in the unmapped_url. This avoids 
breaking any logic that
+  // depends on the lack of promotion in the client request URL.
+  if (!t_state.unmapped_url.m_url_impl->m_ptr_host) {
+    MIMEField *host_field = 
t_state.hdr_info.client_request.field_find(MIME_FIELD_HOST, MIME_LEN_HOST);
+    if (host_field) {
+      int host_len;
+      const char *host_name = host_field->value_get(&host_len);
+      if (host_name && host_len) {
+        t_state.unmapped_url.host_set(host_name, host_len);
+      }
+    }
+  }
 
   if (!ret) {
     DebugSM("url_rewrite", "Could not find a valid remapping entry for this 
request [%" PRId64 "]", sm_id);
diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h
index dd81a49..9049891 100644
--- a/proxy/http/HttpTransact.h
+++ b/proxy/http/HttpTransact.h
@@ -976,7 +976,7 @@ public:
     bool api_skip_all_remapping;
 
     bool already_downgraded;
-    URL pristine_url; // pristine url is the url before remap
+    URL unmapped_url; // unmapped url is the effective url before remap
 
     // Http Range: related variables
     RangeSetup_t range_setup;
@@ -1082,7 +1082,6 @@ public:
         url_remap_success(false),
         api_skip_all_remapping(false),
         already_downgraded(false),
-        pristine_url(),
         range_setup(RANGE_NONE),
         num_range_fields(0),
         range_output_cl(0),
@@ -1152,7 +1151,7 @@ public:
 
       url_map.clear();
       arena.reset();
-      pristine_url.clear();
+      unmapped_url.clear();
       hostdb_entry.clear();
 
       delete[] ranges;
diff --git a/proxy/http/remap/RemapProcessor.cc 
b/proxy/http/remap/RemapProcessor.cc
index fd9426e..d24fa5b 100644
--- a/proxy/http/remap/RemapProcessor.cc
+++ b/proxy/http/remap/RemapProcessor.cc
@@ -209,7 +209,7 @@ RemapProcessor::finish_remap(HttpTransact::State *s)
               }
               break;
             case 'o':
-              c = s->pristine_url.string_get_ref(nullptr);
+              c = s->unmapped_url.string_get_ref(nullptr);
               break;
             };
 
diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc
index 4baccc8..4676737 100644
--- a/proxy/logging/LogAccessHttp.cc
+++ b/proxy/logging/LogAccessHttp.cc
@@ -322,9 +322,9 @@ void
 LogAccessHttp::validate_unmapped_url(void)
 {
   if (m_client_req_unmapped_url_canon_len < 0) {
-    if (m_http_sm->t_state.pristine_url.valid()) {
+    if (m_http_sm->t_state.unmapped_url.valid()) {
       int unmapped_url_len;
-      char *unmapped_url = 
m_http_sm->t_state.pristine_url.string_get_ref(&unmapped_url_len);
+      char *unmapped_url = 
m_http_sm->t_state.unmapped_url.string_get_ref(&unmapped_url_len);
 
       if (unmapped_url && unmapped_url[0] != 0) {
         m_client_req_unmapped_url_canon_str =

-- 
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].

Reply via email to