You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/11/08 23:30:26 UTC
[trafficserver] branch 9.2.x updated: Refactors and promotes the
Txn Control mechanism with Get() and Set() (#8428)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.2.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.2.x by this push:
new 49195c5 Refactors and promotes the Txn Control mechanism with Get() and Set() (#8428)
49195c5 is described below
commit 49195c5e9726ee90fedaf1bc3676d156c1aa9c5c
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Sun Oct 17 08:32:59 2021 -0700
Refactors and promotes the Txn Control mechanism with Get() and Set() (#8428)
* Promote TSHttpTxnCntl to stable ts.h
* Refactor the TSHttpTxnCntl() API into explicit GET/SET
This adds
tsapi bool TSHttpTxnCntlGet(TSHttpTxn txnp, TSHttpCntlType ctrl);
tsapi TSReturnCode TSHttpTxnCntlSet(TSHttpTxn txnp, TSHttpCntlType ctrl, bool data);
* Adds support for the API controlled cacheable flags
This adds
TS_HTTP_CNTL_RESPONSE_CACHEABLE
TS_HTTP_CNTL_REQUEST_CACHEABLE
TS_HTTP_CNTL_SERVER_NO_STORE
* Adds support for the TXN debug flag
This adds
TS_HTTP_CNTL_TXN_DEBUG
* Adds the control feature for turning off remapping
This adds
TS_HTTP_CNTL_SKIP_REMAPPING
* Adds docs for new TSHttpTxnCntlGet/Set APIs
* Updates all core plugins to use the new API
(cherry picked from commit 6e10cdc44f571612eefc1df203b79154c08b00c6)
---
.gitignore | 2 +
.../api/functions/TSHttpTxnCntl.en.rst | 36 +++++++
.../api/types/TSHttpCntlType.en.rst | 65 +++++++++++++
include/ts/apidefs.h.in | 11 +++
include/ts/experimental.h | 17 ----
include/ts/ts.h | 6 ++
plugins/cache_promote/cache_promote.cc | 2 +-
.../cache_range_requests/cache_range_requests.cc | 8 +-
plugins/esi/combo_handler.cc | 4 +-
plugins/esi/serverIntercept.cc | 4 +-
plugins/experimental/acme/acme.c | 2 +-
plugins/experimental/cache_fill/cache_fill.cc | 2 +-
plugins/experimental/mysql_remap/mysql_remap.cc | 2 +-
plugins/experimental/slice/slice.cc | 8 +-
plugins/experimental/tls_bridge/tls_bridge.cc | 2 +-
plugins/header_rewrite/operators.cc | 4 +-
plugins/healthchecks/healthchecks.c | 2 +-
plugins/lua/ts_lua_http.c | 4 +-
plugins/lua/ts_lua_http_cntl.c | 21 +++--
plugins/lua/ts_lua_http_config.c | 2 +-
plugins/stats_over_http/stats_over_http.c | 2 +-
plugins/xdebug/xdebug.cc | 8 +-
src/traffic_server/InkAPI.cc | 105 +++++++++++++--------
src/traffic_server/InkAPITest.cc | 12 +--
src/tscpp/api/Transaction.cc | 2 +-
25 files changed, 232 insertions(+), 101 deletions(-)
diff --git a/.gitignore b/.gitignore
index 3c027bf..ccf5431 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,8 @@ build/ltsugar.m4
build/ltversion.m4
build/lt~obsolete.m4
+BUILD
+
Makefile
Makefile-pl
config.cache
diff --git a/doc/developer-guide/api/functions/TSHttpTxnCntl.en.rst b/doc/developer-guide/api/functions/TSHttpTxnCntl.en.rst
new file mode 100644
index 0000000..ba367ea
--- /dev/null
+++ b/doc/developer-guide/api/functions/TSHttpTxnCntl.en.rst
@@ -0,0 +1,36 @@
+.. 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.
+
+
+TSHttpTxnCntl
+=============
+
+Synopsis
+--------
+
+.. code-block:: cpp
+
+ #include <ts/ts.h>
+
+.. c:function:: bool TSHttpTxnCntlGet(TSHttpTxn txnp, TSHttpCntlType ctrl)
+.. c:function:: TSReturnCode TSHttpTxnCntlSet(TSHttpTxn txnp, TSHttpCntlType cntl, bool data)
+
+Description
+-----------
+Set or Get the status of various control mechanisms within the HTTP transaction. The control
+type must be one of the values are identified by the enumeration :c:enum:`TSHttpCntlType`. The
+values are boolean values, ``true`` and ``false``. A ``true`` values turns on the transaction
+feature, and the ``false`` value turns it off.
diff --git a/doc/developer-guide/api/types/TSHttpCntlType.en.rst b/doc/developer-guide/api/types/TSHttpCntlType.en.rst
new file mode 100644
index 0000000..4d89dfa
--- /dev/null
+++ b/doc/developer-guide/api/types/TSHttpCntlType.en.rst
@@ -0,0 +1,65 @@
+.. 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.
+
+.. include:: ../../../common.defs
+
+TSHttpCntlType
+**************
+
+Synopsis
+========
+
+.. code-block:: cpp
+
+ #include <ts/apidefs.h>
+
+.. c:enum:: TSHttpCntlType
+
+ The feature to control.
+
+ .. c:enumerator:: TS_HTTP_CNTL_LOGGING_MODE
+
+ Turn off (or on) all logging for this transaction.
+
+ .. c:enumerator:: TS_HTTP_CNTL_INTERCEPT_RETRY_MODE
+
+ Control the intercept retry mode.
+
+ .. c:enumerator:: TS_HTTP_CNTL_RESPONSE_CACHEABLE
+
+ Make the response cacheable or uncacheable.
+
+ .. c:enumerator:: TS_HTTP_CNTL_REQUEST_CACHEABLE
+
+ Make the request cacheable or uncacheable.
+
+ .. c:enumerator:: TS_HTTP_CNTL_SERVER_NO_STORE
+
+ Make the server response uncacheable.
+
+ .. c:enumerator:: TS_HTTP_CNTL_TXN_DEBUG
+
+ Turn on transaction debugging.
+
+ .. c:enumerator:: TS_HTTP_CNTL_SKIP_REMAPPING
+
+ Skip the remap requirement for this transaction.
+
+Description
+===========
+
+These enumeration members are used together with the APIs to Set and Get
+control status of a transaction.
diff --git a/include/ts/apidefs.h.in b/include/ts/apidefs.h.in
index c7c8a18..d2646cf 100644
--- a/include/ts/apidefs.h.in
+++ b/include/ts/apidefs.h.in
@@ -1427,6 +1427,17 @@ typedef enum {
#define TS_CRUUID_STRING_LEN (TS_UUID_STRING_LEN + 19 + 1) /* UUID-len + len(uint64_t) + '-' */
typedef struct tsapi_uuid *TSUuid;
+/* Various HTTP "control" modes */
+typedef enum {
+ TS_HTTP_CNTL_LOGGING_MODE,
+ TS_HTTP_CNTL_INTERCEPT_RETRY_MODE,
+ TS_HTTP_CNTL_RESPONSE_CACHEABLE,
+ TS_HTTP_CNTL_REQUEST_CACHEABLE,
+ TS_HTTP_CNTL_SERVER_NO_STORE,
+ TS_HTTP_CNTL_TXN_DEBUG,
+ TS_HTTP_CNTL_SKIP_REMAPPING
+} TSHttpCntlType;
+
#ifdef __cplusplus
namespace ts
{
diff --git a/include/ts/experimental.h b/include/ts/experimental.h
index 73d2cfb..deef0ab 100644
--- a/include/ts/experimental.h
+++ b/include/ts/experimental.h
@@ -73,23 +73,6 @@ int64_t TSCacheHttpInfoSizeGet(TSCacheHttpInfo infop);
tsapi int TSMimeHdrFieldEqual(TSMBuffer bufp, TSMLoc hdr_obj, TSMLoc field1, TSMLoc field2);
tsapi TSReturnCode TSHttpTxnHookRegisteredFor(TSHttpTxn txnp, TSHttpHookID id, TSEventFunc funcp);
-/* Various HTTP "control" modes */
-typedef enum {
- TS_HTTP_CNTL_GET_LOGGING_MODE,
- TS_HTTP_CNTL_SET_LOGGING_MODE,
- TS_HTTP_CNTL_GET_INTERCEPT_RETRY_MODE,
- TS_HTTP_CNTL_SET_INTERCEPT_RETRY_MODE
-} TSHttpCntlType;
-
-#define TS_HTTP_CNTL_OFF (void *)0
-#define TS_HTTP_CNTL_ON (void *)1
-/* usage:
- void *onoff = 0;
- TSHttpTxnCntl(.., TS_HTTP_CNTL_GET_LOGGING_MODE, &onoff);
- if (onoff == TS_HTTP_CNTL_ON) ....
-*/
-tsapi TSReturnCode TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data);
-
/* Protocols APIs */
tsapi void TSVConnCacheHttpInfoSet(TSVConn connp, TSCacheHttpInfo infop);
diff --git a/include/ts/ts.h b/include/ts/ts.h
index fd77272..dc1ac25 100644
--- a/include/ts/ts.h
+++ b/include/ts/ts.h
@@ -2714,6 +2714,12 @@ tsapi TSReturnCode TSHostStatusGet(const char *hostname, const size_t hostname_l
tsapi void TSHostStatusSet(const char *hostname, const size_t hostname_len, TSHostStatus status, const unsigned int down_time,
const unsigned int reason);
+/*
+ * Set or get various HTTP Transaction control settings.
+ */
+tsapi bool TSHttpTxnCntlGet(TSHttpTxn txnp, TSHttpCntlType ctrl);
+tsapi TSReturnCode TSHttpTxnCntlSet(TSHttpTxn txnp, TSHttpCntlType ctrl, bool data);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/plugins/cache_promote/cache_promote.cc b/plugins/cache_promote/cache_promote.cc
index d8fe0a8..aca0daf 100644
--- a/plugins/cache_promote/cache_promote.cc
+++ b/plugins/cache_promote/cache_promote.cc
@@ -68,7 +68,7 @@ cont_handle_policy(TSCont contp, TSEvent event, void *edata)
// transaction is terminated early.
TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, contp);
}
- TSHttpTxnServerRespNoStoreSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SERVER_NO_STORE, true);
}
break;
default:
diff --git a/plugins/cache_range_requests/cache_range_requests.cc b/plugins/cache_range_requests/cache_range_requests.cc
index 1b777d3..7e64ae8 100644
--- a/plugins/cache_range_requests/cache_range_requests.cc
+++ b/plugins/cache_range_requests/cache_range_requests.cc
@@ -227,9 +227,9 @@ range_header_check(TSHttpTxn txnp, pluginconfig *const pc)
} else {
ERROR_LOG("failed to change the cache url to '%s'", cache_key_url);
ERROR_LOG("Disabling cache for this transaction to avoid cache poisoning.");
- TSHttpTxnServerRespNoStoreSet(txnp, 1);
- TSHttpTxnRespCacheableSet(txnp, 0);
- TSHttpTxnReqCacheableSet(txnp, 0);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SERVER_NO_STORE, true);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_RESPONSE_CACHEABLE, false);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_REQUEST_CACHEABLE, false);
}
}
@@ -388,7 +388,7 @@ handle_server_read_response(TSHttpTxn txnp, txndata *const txn_state)
}
} else if (TS_HTTP_STATUS_OK == status) {
DEBUG_LOG("The origin does not support range requests, attempting to disable cache write.");
- if (TS_SUCCESS == TSHttpTxnServerRespNoStoreSet(txnp, 1)) {
+ if (TS_SUCCESS == TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SERVER_NO_STORE, true)) {
DEBUG_LOG("Cache write has been disabled for this transaction.");
} else {
DEBUG_LOG("Unable to disable cache write for this transaction.");
diff --git a/plugins/esi/combo_handler.cc b/plugins/esi/combo_handler.cc
index 1eeb42e..576dcee 100644
--- a/plugins/esi/combo_handler.cc
+++ b/plugins/esi/combo_handler.cc
@@ -495,8 +495,8 @@ handleReadRequestHeader(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edat
InterceptData *int_data = new InterceptData(contp);
TSContDataSet(contp, int_data);
// todo: check if these two cacheable sets are required
- TSHttpTxnReqCacheableSet(txnp, 1);
- TSHttpTxnRespCacheableSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_RESPONSE_CACHEABLE, true);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_REQUEST_CACHEABLE, true);
getClientRequest(txnp, bufp, hdr_loc, url_loc, int_data->creq);
LOG_DEBUG("Setup server intercept to handle client request");
}
diff --git a/plugins/esi/serverIntercept.cc b/plugins/esi/serverIntercept.cc
index 2dc541f..8c4db89 100644
--- a/plugins/esi/serverIntercept.cc
+++ b/plugins/esi/serverIntercept.cc
@@ -356,8 +356,8 @@ setupServerIntercept(TSHttpTxn txnp)
SContData *cont_data = new SContData(contp);
TSContDataSet(contp, cont_data);
TSHttpTxnServerIntercept(contp, txnp);
- TSHttpTxnReqCacheableSet(txnp, 1);
- TSHttpTxnRespCacheableSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_RESPONSE_CACHEABLE, true);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_REQUEST_CACHEABLE, true);
TSDebug(DEBUG_TAG, "[%s] Setup server intercept successfully", __FUNCTION__);
return true;
}
diff --git a/plugins/experimental/acme/acme.c b/plugins/experimental/acme/acme.c
index afb0457..2a01c4f 100644
--- a/plugins/experimental/acme/acme.c
+++ b/plugins/experimental/acme/acme.c
@@ -269,7 +269,7 @@ acme_hook(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata)
goto cleanup;
}
- TSSkipRemappingSet(txnp, 1); /* not strictly necessary, but speed is everything these days */
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true); /* not strictly necessary, but speed is everything these days */
/* This request is for us -- register our intercept */
icontp = TSContCreate(acme_intercept, TSMutexCreate());
diff --git a/plugins/experimental/cache_fill/cache_fill.cc b/plugins/experimental/cache_fill/cache_fill.cc
index 17b8607..1ff2a52 100644
--- a/plugins/experimental/cache_fill/cache_fill.cc
+++ b/plugins/experimental/cache_fill/cache_fill.cc
@@ -113,7 +113,7 @@ cont_handle_cache(TSCont contp, TSEvent event, void *edata)
if (requested) // Made a background fetch request, do not cache the response
{
TSDebug(PLUGIN_NAME, "setting no store");
- TSHttpTxnServerRespNoStoreSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SERVER_NO_STORE, true);
TSHttpTxnCacheLookupStatusSet(txnp, TS_CACHE_LOOKUP_MISS);
}
diff --git a/plugins/experimental/mysql_remap/mysql_remap.cc b/plugins/experimental/mysql_remap/mysql_remap.cc
index 2d1551a..95cd1343 100644
--- a/plugins/experimental/mysql_remap/mysql_remap.cc
+++ b/plugins/experimental/mysql_remap/mysql_remap.cc
@@ -157,7 +157,7 @@ mysql_remap(TSCont contp, TSEvent event, void *edata)
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
TSDebug(PLUGIN_NAME, "Reading Request");
- TSSkipRemappingSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true);
if (!do_mysql_remap(contp, txnp)) {
reenable = TS_EVENT_HTTP_ERROR;
}
diff --git a/plugins/experimental/slice/slice.cc b/plugins/experimental/slice/slice.cc
index 4b71363..fbcd643 100644
--- a/plugins/experimental/slice/slice.cc
+++ b/plugins/experimental/slice/slice.cc
@@ -68,9 +68,9 @@ read_request(TSHttpTxn txnp, Config *const config)
}
// turn off any and all transaction caching (shouldn't matter)
- TSHttpTxnServerRespNoStoreSet(txnp, 1);
- TSHttpTxnRespCacheableSet(txnp, 0);
- TSHttpTxnReqCacheableSet(txnp, 0);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SERVER_NO_STORE, true);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_RESPONSE_CACHEABLE, false);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_REQUEST_CACHEABLE, false);
DEBUG_LOG("slice accepting and slicing");
// connection back into ATS
@@ -177,7 +177,7 @@ read_request(TSHttpTxn txnp, Config *const config)
TSContDataSet(icontp, (void *)data);
// Skip remap and remap rule requirement
- TSSkipRemappingSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true);
// Grab the transaction
TSHttpTxnIntercept(icontp, txnp);
diff --git a/plugins/experimental/tls_bridge/tls_bridge.cc b/plugins/experimental/tls_bridge/tls_bridge.cc
index 435af57..d9622e7 100644
--- a/plugins/experimental/tls_bridge/tls_bridge.cc
+++ b/plugins/experimental/tls_bridge/tls_bridge.cc
@@ -673,7 +673,7 @@ CB_Read_Request_Hdr(TSCont contp, TSEvent ev_idx, void *data)
// Arrange for cleanup.
TSHttpTxnHookAdd(txn, TS_HTTP_TXN_CLOSE_HOOK, actor);
// Skip remap and remap rule requirement - authorized by TLS bridge config.
- TSSkipRemappingSet(txn, 1);
+ TSHttpTxnCntlSet(txn, TS_HTTP_CNTL_SKIP_REMAPPING, true);
// Grab the transaction
TSHttpTxnIntercept(actor, txn);
}
diff --git a/plugins/header_rewrite/operators.cc b/plugins/header_rewrite/operators.cc
index 90b89bc..99be6a8 100644
--- a/plugins/header_rewrite/operators.cc
+++ b/plugins/header_rewrite/operators.cc
@@ -562,7 +562,7 @@ void
OperatorSkipRemap::exec(const Resources &res) const
{
TSDebug(PLUGIN_NAME, "OperatorSkipRemap::exec() skipping remap: %s", _skip_remap ? "True" : "False");
- TSSkipRemappingSet(res.txnp, _skip_remap ? 1 : 0);
+ TSHttpTxnCntlSet(res.txnp, TS_HTTP_CNTL_SKIP_REMAPPING, _skip_remap);
}
// OperatorRMHeader
@@ -1025,5 +1025,5 @@ OperatorSetDebug::initialize_hooks()
void
OperatorSetDebug::exec(const Resources &res) const
{
- TSHttpTxnDebugSet(res.txnp, 1);
+ TSHttpTxnCntlSet(res.txnp, TS_HTTP_CNTL_TXN_DEBUG, true);
}
diff --git a/plugins/healthchecks/healthchecks.c b/plugins/healthchecks/healthchecks.c
index e48e601..6f73b0d 100644
--- a/plugins/healthchecks/healthchecks.c
+++ b/plugins/healthchecks/healthchecks.c
@@ -518,7 +518,7 @@ health_check_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *eda
goto cleanup;
}
- TSSkipRemappingSet(txnp, 1); /* not strictly necessary, but speed is everything these days */
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true); /* not strictly necessary, but speed is everything these days */
/* This is us -- register our intercept */
icontp = TSContCreate(hc_intercept, TSMutexCreate());
diff --git a/plugins/lua/ts_lua_http.c b/plugins/lua/ts_lua_http.c
index 3cd4aec..80ec275 100644
--- a/plugins/lua/ts_lua_http.c
+++ b/plugins/lua/ts_lua_http.c
@@ -610,7 +610,7 @@ ts_lua_http_set_server_resp_no_store(lua_State *L)
status = luaL_checknumber(L, 1);
- TSHttpTxnServerRespNoStoreSet(http_ctx->txnp, status);
+ TSHttpTxnCntlSet(http_ctx->txnp, TS_HTTP_CNTL_SERVER_NO_STORE, (status != 0));
return 0;
}
@@ -787,7 +787,7 @@ ts_lua_http_skip_remapping_set(lua_State *L)
action = luaL_checkinteger(L, 1);
- TSSkipRemappingSet(http_ctx->txnp, action);
+ TSHttpTxnCntlSet(http_ctx->txnp, TS_HTTP_CNTL_SKIP_REMAPPING, (action != 0));
return 0;
}
diff --git a/plugins/lua/ts_lua_http_cntl.c b/plugins/lua/ts_lua_http_cntl.c
index 329bdbb..c30bb27 100644
--- a/plugins/lua/ts_lua_http_cntl.c
+++ b/plugins/lua/ts_lua_http_cntl.c
@@ -19,15 +19,20 @@
#include "ts_lua_util.h"
typedef enum {
- TS_LUA_HTTP_CNTL_GET_LOGGING_MODE = TS_HTTP_CNTL_GET_LOGGING_MODE,
- TS_LUA_HTTP_CNTL_SET_LOGGING_MODE = TS_HTTP_CNTL_SET_LOGGING_MODE,
- TS_LUA_HTTP_CNTL_GET_INTERCEPT_RETRY_MODE = TS_HTTP_CNTL_GET_INTERCEPT_RETRY_MODE,
- TS_LUA_HTTP_CNTL_SET_INTERCEPT_RETRY_MODE = TS_HTTP_CNTL_SET_INTERCEPT_RETRY_MODE
+ TS_LUA_HTTP_CNTL_LOGGING_MODE = TS_HTTP_CNTL_LOGGING_MODE,
+ TS_LUA_HTTP_CNTL_INTERCEPT_RETRY_MODE = TS_HTTP_CNTL_INTERCEPT_RETRY_MODE,
+ TS_LUA_HTTP_CNTL_RESPONSE_CACHEABLE = TS_HTTP_CNTL_RESPONSE_CACHEABLE,
+ TS_LUA_HTTP_CNTL_REQUEST_CACHEABLE = TS_HTTP_CNTL_REQUEST_CACHEABLE,
+ TS_LUA_HTTP_CNTL_SERVER_NO_STORE = TS_HTTP_CNTL_SERVER_NO_STORE,
+ TS_LUA_HTTP_CNTL_TXN_DEBUG = TS_HTTP_CNTL_TXN_DEBUG,
+ TS_LUA_HTTP_CNTL_SKIP_REMAPPING = TS_HTTP_CNTL_SKIP_REMAPPING
} TSLuaHttpCntlType;
ts_lua_var_item ts_lua_http_cntl_type_vars[] = {
- TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_GET_LOGGING_MODE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_SET_LOGGING_MODE),
- TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_GET_INTERCEPT_RETRY_MODE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_SET_INTERCEPT_RETRY_MODE)};
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_LOGGING_MODE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_INTERCEPT_RETRY_MODE),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_RESPONSE_CACHEABLE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_REQUEST_CACHEABLE),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_SERVER_NO_STORE), TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_TXN_DEBUG),
+ TS_LUA_MAKE_VAR_ITEM(TS_LUA_HTTP_CNTL_SKIP_REMAPPING)};
static void ts_lua_inject_http_cntl_variables(lua_State *L);
@@ -69,7 +74,7 @@ ts_lua_http_cntl_set(lua_State *L)
cntl_type = luaL_checkinteger(L, 1);
value = luaL_checkinteger(L, 2);
- TSHttpTxnCntl(http_ctx->txnp, cntl_type, value ? TS_HTTP_CNTL_ON : TS_HTTP_CNTL_OFF);
+ TSHttpTxnCntlSet(http_ctx->txnp, cntl_type, value ? true : false);
return 0;
}
@@ -85,7 +90,7 @@ ts_lua_http_cntl_get(lua_State *L)
cntl_type = luaL_checkinteger(L, 1);
- TSHttpTxnCntl(http_ctx->txnp, cntl_type, &value);
+ value = (int64_t)TSHttpTxnCntlGet(http_ctx->txnp, cntl_type);
lua_pushnumber(L, value);
diff --git a/plugins/lua/ts_lua_http_config.c b/plugins/lua/ts_lua_http_config.c
index 3f47762..310b068 100644
--- a/plugins/lua/ts_lua_http_config.c
+++ b/plugins/lua/ts_lua_http_config.c
@@ -601,7 +601,7 @@ ts_lua_http_set_debug(lua_State *L)
value = luaL_checkinteger(L, 1);
TSDebug(TS_LUA_DEBUG_TAG, "set debug");
- TSHttpTxnDebugSet(http_ctx->txnp, value);
+ TSHttpTxnCntlSet(http_ctx->txnp, TS_HTTP_CNTL_TXN_DEBUG, (value != 0));
return 0;
}
diff --git a/plugins/stats_over_http/stats_over_http.c b/plugins/stats_over_http/stats_over_http.c
index 7ab65d5..bb75fe7 100644
--- a/plugins/stats_over_http/stats_over_http.c
+++ b/plugins/stats_over_http/stats_over_http.c
@@ -592,7 +592,7 @@ stats_origin(TSCont contp ATS_UNUSED, TSEvent event ATS_UNUSED, void *edata)
goto notforme;
}
- TSSkipRemappingSet(txnp, 1); // not strictly necessary, but speed is everything these days
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true); // not strictly necessary, but speed is everything these days
/* This is us -- register our intercept */
TSDebug(PLUGIN_NAME, "Intercepting request");
diff --git a/plugins/xdebug/xdebug.cc b/plugins/xdebug/xdebug.cc
index 9d34655..6943871 100644
--- a/plugins/xdebug/xdebug.cc
+++ b/plugins/xdebug/xdebug.cc
@@ -644,7 +644,7 @@ XScanRequestHeaders(TSCont /* contp */, TSEvent event, void *edata)
TSHttpTxnConfigIntSet(txn, TS_CONFIG_HTTP_INSERT_RESPONSE_VIA_STR, 3);
} else if (header_field_eq("diags", value, vsize)) {
// Enable diagnostics for DebugTxn()'s only
- TSHttpTxnDebugSet(txn, 1);
+ TSHttpTxnCntlSet(txn, TS_HTTP_CNTL_TXN_DEBUG, true);
} else if (header_field_eq("probe", value, vsize)) {
xheaders |= XHEADER_X_PROBE_HEADERS;
@@ -661,9 +661,9 @@ XScanRequestHeaders(TSCont /* contp */, TSEvent event, void *edata)
TSHttpTxnHookAdd(txn, TS_HTTP_RESPONSE_TRANSFORM_HOOK, connp);
// disable writing to cache because we are injecting data into the body.
- TSHttpTxnReqCacheableSet(txn, 0);
- TSHttpTxnRespCacheableSet(txn, 0);
- TSHttpTxnServerRespNoStoreSet(txn, 1);
+ TSHttpTxnCntlSet(txn, TS_HTTP_CNTL_RESPONSE_CACHEABLE, false);
+ TSHttpTxnCntlSet(txn, TS_HTTP_CNTL_REQUEST_CACHEABLE, false);
+ TSHttpTxnCntlSet(txn, TS_HTTP_CNTL_SERVER_NO_STORE, true);
TSHttpTxnTransformedRespCache(txn, 0);
TSHttpTxnUntransformedRespCache(txn, 0);
diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc
index 0b0b987..779658e 100644
--- a/src/traffic_server/InkAPI.cc
+++ b/src/traffic_server/InkAPI.cc
@@ -6549,68 +6549,91 @@ TSHttpTxnStatusGet(TSHttpTxn txnp)
return static_cast<TSHttpStatus>(sm->t_state.http_return_code);
}
-/* control channel for HTTP */
TSReturnCode
-TSHttpTxnCntl(TSHttpTxn txnp, TSHttpCntlType cntl, void *data)
+TSHttpTxnCntlSet(TSHttpTxn txnp, TSHttpCntlType cntl, bool data)
{
sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
HttpSM *sm = (HttpSM *)txnp;
switch (cntl) {
- case TS_HTTP_CNTL_GET_LOGGING_MODE: {
- if (data == nullptr) {
- return TS_ERROR;
- }
+ case TS_HTTP_CNTL_LOGGING_MODE:
+ sm->t_state.api_info.logging_enabled = data;
+ break;
- intptr_t *rptr = static_cast<intptr_t *>(data);
+ case TS_HTTP_CNTL_INTERCEPT_RETRY_MODE:
+ sm->t_state.api_info.retry_intercept_failures = data;
+ break;
- if (sm->t_state.api_info.logging_enabled) {
- *rptr = (intptr_t)TS_HTTP_CNTL_ON;
- } else {
- *rptr = (intptr_t)TS_HTTP_CNTL_OFF;
- }
+ case TS_HTTP_CNTL_RESPONSE_CACHEABLE:
+ sm->t_state.api_resp_cacheable = data;
+ break;
- return TS_SUCCESS;
+ case TS_HTTP_CNTL_REQUEST_CACHEABLE:
+ sm->t_state.api_req_cacheable = data;
+ break;
+
+ case TS_HTTP_CNTL_SERVER_NO_STORE:
+ sm->t_state.api_server_response_no_store = data;
+ break;
+
+ case TS_HTTP_CNTL_TXN_DEBUG:
+ sm->debug_on = data;
+ break;
+
+ case TS_HTTP_CNTL_SKIP_REMAPPING:
+ sm->t_state.api_skip_all_remapping = data;
+ break;
+
+ default:
+ return TS_ERROR;
+ break;
}
- case TS_HTTP_CNTL_SET_LOGGING_MODE:
- if (data != TS_HTTP_CNTL_ON && data != TS_HTTP_CNTL_OFF) {
- return TS_ERROR;
- } else {
- sm->t_state.api_info.logging_enabled = (bool)data;
- return TS_SUCCESS;
- }
+ return TS_SUCCESS;
+}
+
+bool
+TSHttpTxnCntlGet(TSHttpTxn txnp, TSHttpCntlType ctrl)
+{
+ sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
+
+ HttpSM *sm = (HttpSM *)txnp;
+
+ switch (ctrl) {
+ case TS_HTTP_CNTL_LOGGING_MODE:
+ return sm->t_state.api_info.logging_enabled;
break;
- case TS_HTTP_CNTL_GET_INTERCEPT_RETRY_MODE: {
- if (data == nullptr) {
- return TS_ERROR;
- }
+ case TS_HTTP_CNTL_INTERCEPT_RETRY_MODE:
+ return sm->t_state.api_info.retry_intercept_failures;
+ break;
- intptr_t *rptr = static_cast<intptr_t *>(data);
+ case TS_HTTP_CNTL_RESPONSE_CACHEABLE:
+ return sm->t_state.api_resp_cacheable;
+ break;
- if (sm->t_state.api_info.retry_intercept_failures) {
- *rptr = (intptr_t)TS_HTTP_CNTL_ON;
- } else {
- *rptr = (intptr_t)TS_HTTP_CNTL_OFF;
- }
+ case TS_HTTP_CNTL_REQUEST_CACHEABLE:
+ return sm->t_state.api_req_cacheable;
+ break;
- return TS_SUCCESS;
- }
+ case TS_HTTP_CNTL_SERVER_NO_STORE:
+ return sm->t_state.api_server_response_no_store;
+ break;
+
+ case TS_HTTP_CNTL_TXN_DEBUG:
+ return sm->debug_on;
+ break;
+
+ case TS_HTTP_CNTL_SKIP_REMAPPING:
+ return sm->t_state.api_skip_all_remapping;
+ break;
- case TS_HTTP_CNTL_SET_INTERCEPT_RETRY_MODE:
- if (data != TS_HTTP_CNTL_ON && data != TS_HTTP_CNTL_OFF) {
- return TS_ERROR;
- } else {
- sm->t_state.api_info.retry_intercept_failures = (bool)data;
- return TS_SUCCESS;
- }
default:
- return TS_ERROR;
+ break;
}
- return TS_ERROR;
+ return false; // Unknown here, but oh well.
}
/* This is kinda horky, we have to use TSServerState instead of
diff --git a/src/traffic_server/InkAPITest.cc b/src/traffic_server/InkAPITest.cc
index 856ea71..5fc5a10 100644
--- a/src/traffic_server/InkAPITest.cc
+++ b/src/traffic_server/InkAPITest.cc
@@ -3423,7 +3423,7 @@ mytest_handler(TSCont contp, TSEvent event, void *data)
if (test->hook_mask == 1) {
test->hook_mask |= 2;
}
- TSSkipRemappingSet(static_cast<TSHttpTxn>(data), 1);
+ TSHttpTxnCntlSet(static_cast<TSHttpTxn>(data), TS_HTTP_CNTL_SKIP_REMAPPING, true);
checkHttpTxnClientReqGet(test, data);
TSHttpTxnReenable(static_cast<TSHttpTxn>(data), TS_EVENT_HTTP_CONTINUE);
@@ -6973,7 +6973,7 @@ ssn_handler(TSCont contp, TSEvent event, void *edata)
break;
case TS_EVENT_HTTP_TXN_START:
- TSSkipRemappingSet(static_cast<TSHttpTxn>(edata), 1);
+ TSHttpTxnCntlSet(static_cast<TSHttpTxn>(edata), TS_HTTP_CNTL_SKIP_REMAPPING, true);
SDK_RPRINT(data->test, "TSHttpSsnReenable", "TestCase", TC_PASS, "ok");
data->test_passed_ssn_reenable++;
{
@@ -7245,7 +7245,7 @@ parent_proxy_handler(TSCont contp, TSEvent event, void *edata)
TSHttpTxnHookAdd(txnp, TS_HTTP_SEND_RESPONSE_HDR_HOOK, contp);
TSHttpTxnHookAdd(txnp, TS_HTTP_TXN_CLOSE_HOOK, contp);
- TSSkipRemappingSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
@@ -7406,7 +7406,7 @@ cache_hook_handler(TSCont contp, TSEvent event, void *edata)
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
txnp = static_cast<TSHttpTxn>(edata);
- TSSkipRemappingSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
@@ -7876,7 +7876,7 @@ transform_hook_handler(TSCont contp, TSEvent event, void *edata)
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
txnp = static_cast<TSHttpTxn>(edata);
- TSSkipRemappingSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
case TS_EVENT_HTTP_READ_RESPONSE_HDR:
@@ -8165,7 +8165,7 @@ altinfo_hook_handler(TSCont contp, TSEvent event, void *edata)
switch (event) {
case TS_EVENT_HTTP_READ_REQUEST_HDR:
txnp = static_cast<TSHttpTxn>(edata);
- TSSkipRemappingSet(txnp, 1);
+ TSHttpTxnCntlSet(txnp, TS_HTTP_CNTL_SKIP_REMAPPING, true);
TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE);
break;
diff --git a/src/tscpp/api/Transaction.cc b/src/tscpp/api/Transaction.cc
index 8503f1d..1171549 100644
--- a/src/tscpp/api/Transaction.cc
+++ b/src/tscpp/api/Transaction.cc
@@ -280,7 +280,7 @@ Transaction::setCacheUrl(const string &cache_url)
void
Transaction::setSkipRemapping(int flag)
{
- TSSkipRemappingSet(state_->txn_, flag);
+ TSHttpTxnCntlSet(state_->txn_, TS_HTTP_CNTL_SKIP_REMAPPING, flag);
}
const sockaddr *