trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sudhe...@apache.org
Subject [2/4] trafficserver git commit: [TS-3449]: Deprecate TSHttpIsInternalRequest and TSHttpIsInternalSession and replace them with TSHttpTxnIsInternal, TSHttpSsnIsInternal respectively
Date Mon, 06 Apr 2015 19:46:16 GMT
[TS-3449]: Deprecate TSHttpIsInternalRequest and TSHttpIsInternalSession
and replace them with TSHttpTxnIsInternal, TSHttpSsnIsInternal respectively


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

Branch: refs/heads/master
Commit: ed708bd949de18b6af2bc7b78e04bb00bc429afa
Parents: 1818507
Author: Sudheer Vinukonda <sudheerv@yahoo-inc.com>
Authored: Mon Apr 6 19:40:15 2015 +0000
Committer: Sudheer Vinukonda <sudheerv@yahoo-inc.com>
Committed: Mon Apr 6 19:45:06 2015 +0000

----------------------------------------------------------------------
 .../api/TSHttpIsInternalRequest.en.rst          |  4 ++
 doc/reference/api/TSHttpTxnIsInternal.en.rst    | 59 ++++++++++++++++++++
 .../ats_pagespeed/ats_resource_intercept.cc     |  2 +-
 plugins/experimental/authproxy/authproxy.cc     |  2 +-
 .../background_fetch/background_fetch.cc        |  2 +-
 .../experimental/buffer_upload/buffer_upload.cc |  2 +-
 plugins/experimental/esi/esi.cc                 |  2 +-
 .../stale_while_revalidate.c                    |  2 +-
 plugins/experimental/ts_lua/ts_lua_http.c       |  2 +-
 plugins/header_rewrite/conditions.cc            |  2 +-
 plugins/tcpinfo/tcpinfo.cc                      |  2 +-
 proxy/InkAPI.cc                                 | 26 ++++++++-
 proxy/api/ts/ts.h                               |  9 ++-
 13 files changed, 104 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/doc/reference/api/TSHttpIsInternalRequest.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSHttpIsInternalRequest.en.rst b/doc/reference/api/TSHttpIsInternalRequest.en.rst
index 2ac5b2d..26a9a6a 100644
--- a/doc/reference/api/TSHttpIsInternalRequest.en.rst
+++ b/doc/reference/api/TSHttpIsInternalRequest.en.rst
@@ -35,9 +35,13 @@ Description
 :func:`TSHttpIsInternalRequest` tests whether a HTTP transaction
 was originated within Traffic Server.
 
+.. admonition:: Deprecated
+
 :func:`TSHttpIsInternalSession` tests whether a HTTP session
 was originated within Traffic Server.
 
+.. admonition:: Deprecated
+
 Return Values
 =============
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/doc/reference/api/TSHttpTxnIsInternal.en.rst
----------------------------------------------------------------------
diff --git a/doc/reference/api/TSHttpTxnIsInternal.en.rst b/doc/reference/api/TSHttpTxnIsInternal.en.rst
new file mode 100644
index 0000000..9c09177
--- /dev/null
+++ b/doc/reference/api/TSHttpTxnIsInternal.en.rst
@@ -0,0 +1,59 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+   
+       http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+.. default-domain:: c
+
+=======================
+TSHttpTxnIsInternal
+=======================
+
+Test whether a request is internally-generated.
+
+Synopsis
+========
+`#include <ts/ts.h>`
+
+.. function:: TSReturnCode TSHttpTxnIsInternal(TSHttpTxn txnp)
+.. function:: TSReturnCode TSHttpSsnIsInternal(TSHttpSsn ssnp)
+
+Description
+===========
+
+:func:`TSHttpTxnIsInternal` tests whether a HTTP transaction
+was originated within Traffic Server.
+
+:func:`TSHttpSsnIsInternal` tests whether a HTTP session
+was originated within Traffic Server.
+
+Return Values
+=============
+
+Both these APIs returns a :type:`TSReturnCode`, indicating whether the
+object was internal (:data:`TS_SUCCESS`) or not (:data:`TS_ERROR`).
+
+Examples
+========
+
+The ESI plugin uses :func:`TSHttpTxnIsInternal` to ignore requests that is
+had generated while fetching portions of an ESI document:
+
+.. literalinclude:: ../../../plugins/experimental/esi/esi.cc
+  :language: c
+  :lines: 1395-1398
+
+See also
+========
+:manpage:`TSAPI(3ts)`

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/experimental/ats_pagespeed/ats_resource_intercept.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/ats_pagespeed/ats_resource_intercept.cc b/plugins/experimental/ats_pagespeed/ats_resource_intercept.cc
index 0ad84d5..f6c7260 100644
--- a/plugins/experimental/ats_pagespeed/ats_resource_intercept.cc
+++ b/plugins/experimental/ats_pagespeed/ats_resource_intercept.cc
@@ -233,7 +233,7 @@ read_cache_header_callback(TSCont cont, TSEvent event, void *edata)
   // This is because I realised too late that the intercepts
   // are able to outlive the transaction, which I hacked
   // to work.
-  if (TSHttpIsInternalRequest(txn) == TS_SUCCESS) {
+  if (TSHttpTxnIsInternal(txn) == TS_SUCCESS) {
     ats_ctx_destroy(ctx);
     TSHttpTxnReenable(txn, TS_EVENT_HTTP_CONTINUE);
     return 0;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/experimental/authproxy/authproxy.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/authproxy/authproxy.cc b/plugins/experimental/authproxy/authproxy.cc
index 94aada1..31d831e 100644
--- a/plugins/experimental/authproxy/authproxy.cc
+++ b/plugins/experimental/authproxy/authproxy.cc
@@ -638,7 +638,7 @@ AuthProxyGlobalHook(TSCont /* cont ATS_UNUSED */, TSEvent event, void
*edata)
   switch (event) {
   case TS_EVENT_HTTP_POST_REMAP:
     // Ignore internal requests since we generated them.
-    if (TSHttpIsInternalRequest(txn) == TS_SUCCESS) {
+    if (TSHttpTxnIsInternal(txn) == TS_SUCCESS) {
       // All our internal requests *must* hit the origin since it is the
       // agent that needs to make the authorization decision. We can't
       // allow that to be cached. Note that this only affects the remap

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/experimental/background_fetch/background_fetch.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/background_fetch/background_fetch.cc b/plugins/experimental/background_fetch/background_fetch.cc
index 6c22cf6..3f0f0fb 100644
--- a/plugins/experimental/background_fetch/background_fetch.cc
+++ b/plugins/experimental/background_fetch/background_fetch.cc
@@ -798,7 +798,7 @@ static bool
 is_background_fetch_allowed(TSHttpTxn txnp, BgFetchRuleMap *ri)
 {
   TSDebug(PLUGIN_NAME, "Testing: request is internal?");
-  if (TSHttpIsInternalRequest(txnp) == TS_SUCCESS) {
+  if (TSHttpTxnIsInternal(txnp) == TS_SUCCESS) {
     return false;
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/experimental/buffer_upload/buffer_upload.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/buffer_upload/buffer_upload.cc b/plugins/experimental/buffer_upload/buffer_upload.cc
index b5ab02b..c8ed80a 100644
--- a/plugins/experimental/buffer_upload/buffer_upload.cc
+++ b/plugins/experimental/buffer_upload/buffer_upload.cc
@@ -682,7 +682,7 @@ attach_pvc_plugin(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata)
   case TS_EVENT_HTTP_READ_REQUEST_PRE_REMAP:
 
     // if the request is issued by the TSHttpConnect() in this plugin, don't get in the endless
cycle.
-    if (TSHttpIsInternalRequest(txnp) == TS_SUCCESS) {
+    if (TSHttpTxnIsInternal(txnp) == TS_SUCCESS) {
       TSDebug(DEBUG_TAG, "internal request");
       break;
     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/experimental/esi/esi.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/esi/esi.cc b/plugins/experimental/esi/esi.cc
index 548c0e9..ff3a428 100644
--- a/plugins/experimental/esi/esi.cc
+++ b/plugins/experimental/esi/esi.cc
@@ -1339,7 +1339,7 @@ isCacheObjTransformable(TSHttpTxn txnp, bool *intercept_header, bool
*head_only)
 static bool
 isInterceptRequest(TSHttpTxn txnp)
 {
-  if (TSHttpIsInternalRequest(txnp) != TS_SUCCESS) {
+  if (TSHttpTxnIsInternal(txnp) != TS_SUCCESS) {
     TSDebug(DEBUG_TAG, "[%s] Skipping external request", __FUNCTION__);
     return false;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c b/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
index c3cd9bc..5e7d77c 100644
--- a/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
+++ b/plugins/experimental/stale_while_revalidate/stale_while_revalidate.c
@@ -473,7 +473,7 @@ main_plugin(TSCont cont, TSEvent event, void *edata)
   // Is this the proper event?
   case TS_EVENT_HTTP_READ_REQUEST_HDR:
 
-    if (TSHttpIsInternalRequest(txn) != TS_SUCCESS) {
+    if (TSHttpTxnIsInternal(txn) != TS_SUCCESS) {
       TSDebug(PLUGIN_NAME, "External Request");
       plugin_config = (config_t *)TSContDataGet(cont);
       state = TSmalloc(sizeof(StateInfo));

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/experimental/ts_lua/ts_lua_http.c
----------------------------------------------------------------------
diff --git a/plugins/experimental/ts_lua/ts_lua_http.c b/plugins/experimental/ts_lua/ts_lua_http.c
index 618deff..8d84880 100644
--- a/plugins/experimental/ts_lua/ts_lua_http.c
+++ b/plugins/experimental/ts_lua/ts_lua_http.c
@@ -290,7 +290,7 @@ ts_lua_http_is_internal_request(lua_State *L)
 
   http_ctx = ts_lua_get_http_ctx(L);
 
-  ret = TSHttpIsInternalRequest(http_ctx->txnp);
+  ret = TSHttpTxnIsInternal(http_ctx->txnp);
 
   if (ret == TS_SUCCESS) {
     lua_pushnumber(L, 1);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/header_rewrite/conditions.cc
----------------------------------------------------------------------
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index c571b83..f5f1bc0 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -501,7 +501,7 @@ ConditionCookie::eval(const Resources &res)
 bool
 ConditionInternalTransaction::eval(const Resources &res)
 {
-  return TSHttpIsInternalRequest(res.txnp) == TS_SUCCESS;
+  return TSHttpTxnIsInternal(res.txnp) == TS_SUCCESS;
 }
 
 void

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/plugins/tcpinfo/tcpinfo.cc
----------------------------------------------------------------------
diff --git a/plugins/tcpinfo/tcpinfo.cc b/plugins/tcpinfo/tcpinfo.cc
index 007a0af..eeafec5 100644
--- a/plugins/tcpinfo/tcpinfo.cc
+++ b/plugins/tcpinfo/tcpinfo.cc
@@ -206,7 +206,7 @@ tcp_info_hook(TSCont contp, TSEvent event, void *edata)
   }
 
   // Don't try to sample internal requests. TCP metrics for loopback are not interesting.
-  if (TSHttpIsInternalSession(ssnp) == TS_SUCCESS) {
+  if (TSHttpSsnIsInternal(ssnp) == TS_SUCCESS) {
     goto done;
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/proxy/InkAPI.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index f11fbd6..aca133b 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7453,6 +7453,7 @@ TSFetchRespHdrMLocGet(TSFetchSM fetch_sm)
   return ((FetchSM *)fetch_sm)->resp_hdr_mloc();
 }
 
+// Deprecated, remove for v7.0.0
 TSReturnCode
 TSHttpIsInternalSession(TSHttpSsn ssnp)
 {
@@ -7470,12 +7471,35 @@ TSHttpIsInternalSession(TSHttpSsn ssnp)
 }
 
 TSReturnCode
+TSHttpSsnIsInternal(TSHttpSsn ssnp)
+{
+  HttpClientSession *cs = (HttpClientSession *)ssnp;
+  if (!cs) {
+    return TS_ERROR;
+  }
+
+  NetVConnection *vc = cs->get_netvc();
+  if (!vc) {
+    return TS_ERROR;
+  }
+
+  return vc->get_is_internal_request() ? TS_SUCCESS : TS_ERROR;
+}
+
+// Deprecated, remove for v7.0.0
+TSReturnCode
 TSHttpIsInternalRequest(TSHttpTxn txnp)
 {
   sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
-  return TSHttpIsInternalSession(TSHttpTxnSsnGet(txnp));
+  return TSHttpSsnIsInternal(TSHttpTxnSsnGet(txnp));
 }
 
+TSReturnCode
+TSHttpTxnIsInternal(TSHttpTxn txnp)
+{
+  sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+  return TSHttpSsnIsInternal(TSHttpTxnSsnGet(txnp));
+}
 
 TSReturnCode
 TSAIORead(int fd, off_t offset, char *buf, size_t buffSize, TSCont contp)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/ed708bd9/proxy/api/ts/ts.h
----------------------------------------------------------------------
diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h
index 60fb0db..1484836 100644
--- a/proxy/api/ts/ts.h
+++ b/proxy/api/ts/ts.h
@@ -1656,8 +1656,13 @@ tsapi void TSFetchUrl(const char *request, int request_len, struct
sockaddr cons
 tsapi void TSFetchPages(TSFetchUrlParams_t *params);
 
 /* Check if HTTP State machine is internal or not */
-tsapi TSReturnCode TSHttpIsInternalRequest(TSHttpTxn txnp);
-tsapi TSReturnCode TSHttpIsInternalSession(TSHttpSsn ssnp);
+/** @deprecated to be renamed as TSHttpTxnIsInternal **/
+tsapi TS_DEPRECATED TSReturnCode TSHttpIsInternalRequest(TSHttpTxn txnp);
+/** @deprecated to be renamed as TSHttpSsnIsInternal **/
+tsapi TS_DEPRECATED TSReturnCode TSHttpIsInternalSession(TSHttpSsn ssnp);
+
+tsapi TSReturnCode TSHttpTxnIsInternal(TSHttpTxn txnp);
+tsapi TSReturnCode TSHttpSsnIsInternal(TSHttpSsn ssnp);
 
 /* --------------------------------------------------------------------------
    HTTP alternate selection */


Mime
View raw message