Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ build/ltsugar.m4
build/ltversion.m4
build/lt~obsolete.m4

BUILD

Makefile
Makefile-pl
config.cache
Expand Down
36 changes: 36 additions & 0 deletions doc/developer-guide/api/functions/TSHttpTxnCntl.en.rst
Original file line number Diff line number Diff line change
@@ -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.
65 changes: 65 additions & 0 deletions doc/developer-guide/api/types/TSHttpCntlType.en.rst
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions include/ts/apidefs.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,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
{
Expand Down
17 changes: 0 additions & 17 deletions include/ts/experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 6 additions & 0 deletions include/ts/ts.h
Original file line number Diff line number Diff line change
Expand Up @@ -2713,6 +2713,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 */
2 changes: 1 addition & 1 deletion plugins/cache_promote/cache_promote.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions plugins/cache_range_requests/cache_range_requests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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.");
Expand Down
4 changes: 2 additions & 2 deletions plugins/esi/combo_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/esi/serverIntercept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion plugins/experimental/acme/acme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion plugins/experimental/cache_fill/cache_fill.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/experimental/mysql_remap/mysql_remap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions plugins/experimental/slice/slice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion plugins/experimental/tls_bridge/tls_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/header_rewrite/operators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion plugins/healthchecks/healthchecks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions plugins/lua/ts_lua_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
21 changes: 13 additions & 8 deletions plugins/lua/ts_lua_http_cntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion plugins/lua/ts_lua_http_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,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;
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/stats_over_http/stats_over_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,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");
Expand Down
Loading