[ 
https://issues.apache.org/jira/browse/TS-3500?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14486329#comment-14486329
 ] 

Sudheer Vinukonda edited comment on TS-3500 at 4/9/15 12:33 AM:
----------------------------------------------------------------

Discussing on the IRC, [~zwoop] suggested to avoid (unnecessary!!) copy of the 
pristine url and simply make {{TSHttpTxnPristineUrlGet}} return 
client_request's url when pristine url is not set. Below's the proposed patch 
with this change:

{code}
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 0b5490d..24fca80 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -4576,8 +4576,15 @@ TSHttpTxnPristineUrlGet(TSHttpTxn txnp, TSMBuffer *bufp, 
TSMLoc *url_loc)
     *(reinterpret_cast<HTTPHdr**>(bufp)) = hptr;
     *url_loc = (TSMLoc)sm->t_state.pristine_url.m_url_impl;
 
-    if ((sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS) && (*url_loc))
-      return TS_SUCCESS;
+    if (sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS) {
+      if (*url_loc == NULL) {
+        hptr->set_url_target_from_host_field();
+        *url_loc = (TSMLoc)hptr->m_http->u.req.m_url_impl;
+      }
+      if (*url_loc) {
+        return TS_SUCCESS;
+      }
+    }
   }
   return TS_ERROR;
 }
{code}

One concern with the above patch is that a Get() API could end up modifying 
stuff, which is potentially dangerous. 

Another (less efficient) approach is the below patch:

{code}
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index 1648c18..bf2a6b5 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -758,6 +758,10 @@ HttpTransact::StartRemapRequest(State* s)
   if (s->api_skip_all_remapping) {
     Debug ("http_trans", "API request to skip remapping");
 
+    s->hdr_info.client_request.set_url_target_from_host_field();
+    s->pristine_url.create(s->hdr_info.client_request.url_get()->m_heap);
+    s->pristine_url.copy(s->hdr_info.client_request.url_get());
+
     if (s->is_upgrade_request && s->post_remap_upgrade_return_point) {
       TRANSACT_RETURN(SM_ACTION_POST_REMAP_SKIP, 
s->post_remap_upgrade_return_point);
     }
{code}


was (Author: sudheerv):
Discussing on the IRC, [~zwoop] suggested to avoid (unnecessary!!) copy of the 
pristine url and simply make {{TSHttpTxnPristineUrlGet}} return 
client_request's url when pristine url is not set. Below's the proposed patch 
with this change:

{code}
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 0b5490d..24fca80 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -4576,8 +4576,15 @@ TSHttpTxnPristineUrlGet(TSHttpTxn txnp, TSMBuffer *bufp, 
TSMLoc *url_loc)
     *(reinterpret_cast<HTTPHdr**>(bufp)) = hptr;
     *url_loc = (TSMLoc)sm->t_state.pristine_url.m_url_impl;
 
-    if ((sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS) && (*url_loc))
-      return TS_SUCCESS;
+    if (sdk_sanity_check_mbuffer(*bufp) == TS_SUCCESS) {
+      if (*url_loc == NULL) {
+        hptr->set_url_target_from_host_field();
+        *url_loc = (TSMLoc)hptr->m_http->u.req.m_url_impl;
+      }
+      if (*url_loc) {
+        return TS_SUCCESS;
+      }
+    }
   }
   return TS_ERROR;
 }
{code}

> pristine url is not populated when TSSkipRemappingSet is enabled
> ----------------------------------------------------------------
>
>                 Key: TS-3500
>                 URL: https://issues.apache.org/jira/browse/TS-3500
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Core
>            Reporter: Sudheer Vinukonda
>
> pristine url is not populated when TSSkipRemappingSet is enabled



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to