This is an automated email from the ASF dual-hosted git repository.
amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 7c9e456 Via: Revert changes for #1534 and subsequent.
7c9e456 is described below
commit 7c9e45697d8ff13113f5ba4010b7e2a7a042bc2e
Author: Alan M. Carroll <[email protected]>
AuthorDate: Fri Jun 9 04:38:25 2017 -0500
Via: Revert changes for #1534 and subsequent.
---
doc/admin-guide/files/records.config.en.rst | 83 ++++----------
lib/records/I_RecCore.h | 1 -
lib/records/RecCore.cc | 19 ----
lib/ts/apidefs.h.in | 9 --
mgmt/RecordsConfig.cc | 14 +--
plugins/experimental/ts_lua/ts_lua_http_config.c | 4 -
proxy/InkAPI.cc | 30 ------
proxy/InkAPITest.cc | 2 -
proxy/http/HttpConfig.cc | 131 +----------------------
proxy/http/HttpConfig.h | 25 -----
proxy/http/HttpProxyAPIEnums.h | 27 -----
proxy/http/HttpTransactHeaders.cc | 84 +++++++--------
tests/gold_tests/headers/via-compact.gold | 4 -
tests/gold_tests/headers/via-compact.test.py | 114 --------------------
tests/gold_tests/headers/via-observer.py | 6 +-
tests/gold_tests/headers/via.gold | 12 +--
tests/gold_tests/headers/via.test.py | 15 ++-
17 files changed, 83 insertions(+), 497 deletions(-)
diff --git a/doc/admin-guide/files/records.config.en.rst
b/doc/admin-guide/files/records.config.en.rst
index f5e43d8..aaa64a6 100644
--- a/doc/admin-guide/files/records.config.en.rst
+++ b/doc/admin-guide/files/records.config.en.rst
@@ -848,18 +848,19 @@ ip-resolve
Set how the ``Via`` field is handled on a request to the origin server.
- ===== ============================================
+ ===== ====================================================================
Value Effect
- ===== ============================================
+ ===== ====================================================================
``0`` Do not modify or set this Via header.
- ``1`` Update the Via, with normal verbosity.
- ``2`` Update the Via, with higher verbosity.
- ``3`` Update the Via, with highest verbosity.
- ===== ============================================
+ ``1`` Add the basic protocol and proxy identifier.
+ ``2`` Add basic transaction codes.
+ ``3`` Add detailed transaction codes.
+ ``4`` Add full user agent connection :ref:`protocol tags <protocol_tags>`.
+ ===== ====================================================================
.. note::
- The ``Via`` header string can be decoded with the `Via Decoder Ring
<http://trafficserver.apache.org/tools/via>`_.
+ The ``Via`` transaction codes can be decoded with the `Via Decoder Ring
<http://trafficserver.apache.org/tools/via>`_.
.. ts:cv:: CONFIG proxy.config.http.request_via_str STRING
ApacheTrafficServer/${PACKAGE_VERSION}
:reloadable:
@@ -867,47 +868,25 @@ ip-resolve
Set the server and version string in the ``Via`` request header to the
origin server which is inserted when the value of
:ts:cv:`proxy.config.http.insert_request_via_str` is not ``0``. Note that the
actual default value is defined with ``"ApacheTrafficServer/" PACKAGE_VERSION``
in a C++ source code, and you must write such as ``ApacheTrafficServer/6.0.0``
if you really set a value with the version in :file:`records.config` file. If
you want to hide the version, you can set this value [...]
-.. ts:cv:: CONFIG proxy.config.http.request_via_transport STRING compact
- :reloadable:
- :overridable:
-
- The ``Via`` string set by |TS| on an upstream request to the origin server
can contain a
- description of the transport protocols used by the user agent to
- connect to |TS|. This configuration controls the level of detail for the
``Via`` string placed in
- the outbound request.
-
- ======= =================================================================
- Value Effect
- ======= =================================================================
- None No details about the transport protocol.
- Compact Only the top level protocol plus a TLS indicator.
- Full The entire protocol stack of :ref:`protocol_tags <protocol_tags>`
- as a dash separated list.
- ======= =================================================================
-
- The full protocol stack will be a list of :ref:`protocol tags
<protocol_tags>` separated by a '-' character. The set of tags will vary but
not the number of white space separated tokens in the ``Via`` header. The tags
are ordered left to right from top most protocol to lowest level protocol.
-
- The compact form always starts with ``http``. If the connection is TLS an
``s`` is added. The
- HTTP version is a ``/`` followed by one of ``1.0``, ``1.1``, ``2``. E.g.
``http/1.1`` for just HTTP, or ``https/2`` for HTTP/2 over TLS.
-
.. ts:cv:: CONFIG proxy.config.http.insert_response_via_str INT 0
:reloadable:
:overridable:
Set how the ``Via`` field is handled on the response to the client.
- ===== ============================================
+ ===== ==================================================================
Value Effect
- ===== ============================================
- ``0`` Do not modify or set this via header.
- ``1`` Update the via, with normal verbosity.
- ``2`` Update the via, with higher verbosity.
- ``3`` Update the via, with highest verbosity.
- ===== ============================================
+ ===== ==================================================================
+ ``0`` Do not modify or set this Via header.
+ ``1`` Add the basic protocol and proxy identifier.
+ ``2`` Add basic transaction codes.
+ ``3`` Add detailed transaction codes.
+ ``4`` Add full upstream connection :ref:`protocol tags <protocol_tags>`.
+ ===== ==================================================================
.. note::
- The ``Via`` header string can be decoded with the `Via Decoder Ring
<http://trafficserver.apache.org/tools/via>`_.
+ The ``Via`` transaction acode can be decoded with the `Via Decoder Ring
<http://trafficserver.apache.org/tools/via>`_.
.. ts:cv:: CONFIG proxy.config.http.response_via_str STRING
ApacheTrafficServer/${PACKAGE_VERSION}
:reloadable:
@@ -915,32 +894,6 @@ ip-resolve
Set the server and version string in the ``Via`` response header to the
client which is inserted when the value of
:ts:cv:`proxy.config.http.insert_response_via_str` is not ``0``. Note that the
actual default value is defined with ``"ApacheTrafficServer/" PACKAGE_VERSION``
in a C++ source code, and you must write such as ``ApacheTrafficServer/6.0.0``
if you really set a value with the version in :file:`records.config` file. If
you want to hide the version, you can set this value to ` [...]
-.. ts:cv:: CONFIG proxy.config.http.response_via_transport STRING compact
- :reloadable:
- :overridable:
-
- The ``Via`` string set by |TS| in the response to the client can contain a
description of the
- transport protocols used by |TS| to connect to the origin server. This
configuration controls
- the level of detail for the ``Via`` string placed in the response.
-
- ======= =================================================================
- Value Effect
- ======= =================================================================
- None No details about the transport protocol.
- Compact Only the top level protocol plus a TLS indicator.
- Full The entire protocol stack of :ref:`protocol_tags <protocol_tags>`
- as a dash separated list.
- ======= =================================================================
-
- The full protocol stack will be a list of :ref:`protocol tags
<protocol_tags>` separated by a '-'
- character. The set of tags will vary but not the number of white space
separated tokens in the
- ``Via`` header. The tags are ordered left to right from top most protocol
to lowest level
- protocol. Note this list may not have more detail even when set to ``Full``
if |TS| does not
- connect upstream (e.g., the request is a cache hit).
-
- The compact form always starts with ``http``. If the connection is TLS an
``s`` is added. The
- HTTP version is a ``/`` followed by one of ``1.0``, ``1.1``, ``2``. E.g.
``http/1.1`` for just HTTP, or ``https/2`` for HTTP/2 over TLS.
-
.. ts:cv:: CONFIG proxy.config.http.send_100_continue_response INT 0
:reloadable:
@@ -3320,7 +3273,7 @@ Client-Related Configuration
:0: Server Certificate will not be verified
:1: Certificate will be verified and the connection will not be established if
verification fails.
-:2: The provided certificate will be verified and the connection will be
established irrespective of the verification result. If verification fails the
name of the server will be logged.
+:2: The provided certificate will be verified and the connection will be
established irrespective of the verification result. If verification fails the
name of the server will be logged.
.. ts:cv:: CONFIG proxy.config.ssl.client.cert.filename STRING NULL
diff --git a/lib/records/I_RecCore.h b/lib/records/I_RecCore.h
index 358ffd9..da904c7 100644
--- a/lib/records/I_RecCore.h
+++ b/lib/records/I_RecCore.h
@@ -176,7 +176,6 @@ int RecGetRecordBool(const char *name, RecBool *rec_byte,
bool lock = true);
typedef void (*RecLookupCallback)(const RecRecord *, void *);
int RecLookupRecord(const char *name, RecLookupCallback callback, void *data,
bool lock = true);
-int RecLookupRecord(const char *name, std::function<void(const RecRecord *)>
&&f, bool lock = true);
int RecLookupMatchingRecords(unsigned rec_type, const char *match,
RecLookupCallback callback, void *data, bool lock = true);
int RecGetRecordType(const char *name, RecT *rec_type, bool lock = true);
diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc
index 4ef1652..ed8632e 100644
--- a/lib/records/RecCore.cc
+++ b/lib/records/RecCore.cc
@@ -484,25 +484,6 @@ RecLookupRecord(const char *name, void (*callback)(const
RecRecord *, void *), v
return err;
}
-namespace
-{
-// Shim to enable using functors for @c RecLookupRecord.
-// This function is passed to @c RecLookupRecord with a @a data argument that
is a pointer to the functor.
-// When this is called, cast @a data back to the functor and invoke it.
-void
-RecLookupRecordForward(const RecRecord *r, void *data)
-{
- (*static_cast<std::function<void(const RecRecord *)> *>(data))(r);
-}
-}
-
-/// Overload that takes a functor.
-int
-RecLookupRecord(const char *name, std::function<void(const RecRecord *)>
&&callback, bool lock)
-{
- return RecLookupRecord(name, &RecLookupRecordForward, &callback, lock);
-}
-
int
RecLookupMatchingRecords(unsigned rec_type, const char *match, void
(*callback)(const RecRecord *, void *), void *data, bool lock)
{
diff --git a/lib/ts/apidefs.h.in b/lib/ts/apidefs.h.in
index 9c3dd1c..49b7b4b 100644
--- a/lib/ts/apidefs.h.in
+++ b/lib/ts/apidefs.h.in
@@ -567,13 +567,6 @@ typedef enum {
TS_SERVER_SESSION_SHARING_POOL_GLOBAL,
TS_SERVER_SESSION_SHARING_POOL_THREAD,
} TSServerSessionSharingPoolType;
-
-/// The verbosity of the transport protocol stack in a VIA header.
-typedef enum {
- TS_VIA_TRANSPORT_NONE = 0,
- TS_VIA_TRANSPORT_COMPACT = 1,
- TS_VIA_TRANSPORT_FULL = 2
-} TSViaTransportVerbosity;
#endif
/* librecords types */
@@ -757,8 +750,6 @@ typedef enum {
TS_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_LANGUAGE_MISMATCH,
TS_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_ENCODING_MISMATCH,
TS_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_CHARSET_MISMATCH,
- TS_CONFIG_HTTP_REQUEST_VIA_TRANSPORT,
- TS_CONFIG_HTTP_RESPONSE_VIA_TRANSPORT,
TS_CONFIG_LAST_ENTRY
} TSOverridableConfigKey;
diff --git a/mgmt/RecordsConfig.cc b/mgmt/RecordsConfig.cc
index 8a711f8..39bce05 100644
--- a/mgmt/RecordsConfig.cc
+++ b/mgmt/RecordsConfig.cc
@@ -355,24 +355,14 @@ static const RecordElement RecordsConfig[] =
,
{RECT_CONFIG, "proxy.config.http.wait_for_cache", RECD_INT, "0",
RECU_RESTART_TM, RR_NULL, RECC_INT, "[0-3]", RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.http.insert_request_via_str", RECD_INT, "1",
RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
+ {RECT_CONFIG, "proxy.config.http.insert_request_via_str", RECD_INT, "1",
RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-4]", RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.http.insert_response_via_str", RECD_INT, "0",
RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
+ {RECT_CONFIG, "proxy.config.http.insert_response_via_str", RECD_INT, "0",
RECU_DYNAMIC, RR_NULL, RECC_INT, "[0-4]", RECA_NULL}
,
- // # verbose via string
- // #
- // # 0 - no extra info added to string
- // # 1 - minimal information.
- // # 2 - more information
- // # 3 - maximum information.
{RECT_CONFIG, "proxy.config.http.request_via_str", RECD_STRING,
"ApacheTrafficServer/" PACKAGE_VERSION, RECU_DYNAMIC, RR_NULL, RECC_NULL,
nullptr, RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.response_via_str", RECD_STRING,
"ApacheTrafficServer/" PACKAGE_VERSION, RECU_DYNAMIC, RR_NULL, RECC_NULL,
nullptr, RECA_NULL}
,
- {RECT_CONFIG, "proxy.config.http.request_via_transport", RECD_STRING,
"compact", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
- ,
- {RECT_CONFIG, "proxy.config.http.response_via_transport", RECD_STRING,
"compact", RECU_DYNAMIC, RR_NULL, RECC_NULL, nullptr, RECA_NULL}
- ,
{RECT_CONFIG, "proxy.config.http.response_server_enabled", RECD_INT, "1",
RECU_DYNAMIC, RR_NULL, RECC_NULL, "[0-2]", RECA_NULL}
,
{RECT_CONFIG, "proxy.config.http.response_server_str", RECD_STRING, "ATS/"
PACKAGE_VERSION, RECU_DYNAMIC, RR_NULL, RECC_NULL, ".*", RECA_NULL}
diff --git a/plugins/experimental/ts_lua/ts_lua_http_config.c
b/plugins/experimental/ts_lua/ts_lua_http_config.c
index d33d4ed..08d25fe 100644
--- a/plugins/experimental/ts_lua/ts_lua_http_config.c
+++ b/plugins/experimental/ts_lua/ts_lua_http_config.c
@@ -127,8 +127,6 @@ typedef enum {
TS_LUA_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_LANGUAGE_MISMATCH =
TS_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_LANGUAGE_MISMATCH,
TS_LUA_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_ENCODING_MISMATCH =
TS_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_ENCODING_MISMATCH,
TS_LUA_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_CHARSET_MISMATCH =
TS_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_CHARSET_MISMATCH,
- TS_LUA_CONFIG_HTTP_REQUEST_VIA_TRANSPORT =
TS_CONFIG_HTTP_REQUEST_VIA_TRANSPORT,
- TS_LUA_CONFIG_HTTP_RESPONSE_VIA_TRANSPORT =
TS_CONFIG_HTTP_RESPONSE_VIA_TRANSPORT,
TS_LUA_CONFIG_LAST_ENTRY =
TS_CONFIG_LAST_ENTRY,
} TSLuaOverridableConfigKey;
@@ -248,8 +246,6 @@ ts_lua_var_item ts_lua_http_config_vars[] = {
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_LANGUAGE_MISMATCH),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_ENCODING_MISMATCH),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_CACHE_IGNORE_ACCEPT_CHARSET_MISMATCH),
- TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_REQUEST_VIA_TRANSPORT),
- TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_HTTP_RESPONSE_VIA_TRANSPORT),
TS_LUA_MAKE_VAR_ITEM(TS_LUA_CONFIG_LAST_ENTRY),
};
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 9457ac7..42c4e0f 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -7865,12 +7865,6 @@ _conf_to_memberp(TSOverridableConfigKey conf,
OverridableHttpConfigParams *overr
case TS_CONFIG_HTTP_INSERT_RESPONSE_VIA_STR:
ret =
_memberp_to_generic(&overridableHttpConfig->insert_response_via_string, typep);
break;
- case TS_CONFIG_HTTP_REQUEST_VIA_TRANSPORT:
- ret = _memberp_to_generic(&overridableHttpConfig->request_via_transport,
typep);
- break;
- case TS_CONFIG_HTTP_RESPONSE_VIA_TRANSPORT:
- ret = _memberp_to_generic(&overridableHttpConfig->response_via_transport,
typep);
- break;
case TS_CONFIG_HTTP_CACHE_HEURISTIC_MIN_LIFETIME:
ret =
_memberp_to_generic(&overridableHttpConfig->cache_heuristic_min_lifetime,
typep);
break;
@@ -8196,9 +8190,6 @@ TSHttpTxnConfigFloatGet(TSHttpTxn txnp,
TSOverridableConfigKey conf, TSMgmtFloat
TSReturnCode
TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, const
char *value, int length)
{
- extern MgmtByteEnumConversion ViaTransportVerbosityConversion;
- RecEnumData data;
-
sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
if (length == -1) {
@@ -8247,18 +8238,6 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp,
TSOverridableConfigKey conf, const char
s->t_state.txn_conf->client_cert_filepath = const_cast<char *>(value);
}
break;
- case TS_CONFIG_HTTP_RESPONSE_VIA_TRANSPORT:
- data._s.setView(value, length);
- if
(ViaTransportVerbosityConversion(s->t_state.txn_conf->response_via_transport,
"proxy.config.http.response_via_tranport",
- RECD_STRING, data)) {
- }
- break;
- case TS_CONFIG_HTTP_REQUEST_VIA_TRANSPORT:
- data._s.setView(value, length);
- if
(ViaTransportVerbosityConversion(s->t_state.txn_conf->request_via_transport,
"proxy.config.http.request_via_tranport",
- RECD_STRING, data)) {
- }
- break;
default:
return TS_ERROR;
break;
@@ -8462,12 +8441,6 @@ TSHttpTxnConfigFind(const char *name, int length,
TSOverridableConfigKey *conf,
cnf = TS_CONFIG_HTTP_DOC_IN_CACHE_SKIP_DNS;
}
break;
- case 't':
- if (!strncmp(name, "proxy.config.http.request_via_transport", length)) {
- cnf = TS_CONFIG_HTTP_REQUEST_VIA_TRANSPORT;
- typ = TS_RECORDDATATYPE_STRING;
- }
- break;
}
break;
@@ -8508,9 +8481,6 @@ TSHttpTxnConfigFind(const char *name, int length,
TSOverridableConfigKey *conf,
case 't':
if (!strncmp(name, "proxy.config.http.keep_alive_enabled_out", length)) {
cnf = TS_CONFIG_HTTP_KEEP_ALIVE_ENABLED_OUT;
- } else if (!strncmp(name, "proxy.config.http.response_via_transport",
length)) {
- cnf = TS_CONFIG_HTTP_RESPONSE_VIA_TRANSPORT;
- typ = TS_RECORDDATATYPE_STRING;
}
break;
}
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 12b3720..4d20009 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -7607,8 +7607,6 @@ const char *SDK_Overridable_Configs[TS_CONFIG_LAST_ENTRY]
= {
"proxy.config.http.cache.ignore_accept_language_mismatch",
"proxy.config.http.cache.ignore_accept_encoding_mismatch",
"proxy.config.http.cache.ignore_accept_charset_mismatch",
- "proxy.config.http.request_via_transport",
- "proxy.config.http.response_via_transport",
};
REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS)(RegressionTest *test, int /*
atype ATS_UNUSED */, int *pstatus)
{
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index e6eb67a..17d9073 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -31,8 +31,6 @@
#include "P_Net.h"
#include "P_RecUtils.h"
#include <records/I_RecHttp.h>
-#include <ts/MemView.h>
-#include <list>
#define HttpEstablishStaticConfigStringAlloc(_ix, _n) \
REC_EstablishStaticConfigStringAlloc(_ix, _n); \
@@ -67,18 +65,16 @@ public:
/// Data item for enumerated type config value.
template <typename T> struct ConfigEnumPair {
T _value;
- ts::StringView _key;
-
- ConfigEnumPair(T v, char const *k) : _value(v), _key(k) {}
+ const char *_key;
};
/// Convert a string to an enumeration value.
/// @a n is the number of entries in the list.
/// @return @c true if the string is found, @c false if not found.
/// If found @a value is set to the corresponding value in @a list.
-template <typename E, unsigned N>
+template <typename T, unsigned N>
static bool
-http_config_enum_search(ts::StringView key, const ConfigEnumPair<E>
(&list)[N], MgmtByte &value)
+http_config_enum_search(const char *key, const ConfigEnumPair<T> (&list)[N],
MgmtByte &value)
{
// We don't expect any of these lists to be more than 10 long, so a linear
search is the best choice.
for (unsigned i = 0; i < N; ++i) {
@@ -90,13 +86,6 @@ http_config_enum_search(ts::StringView key, const
ConfigEnumPair<E> (&list)[N],
return false;
}
-template <typename E, unsigned N>
-static bool
-http_config_enum_search(const char *key, const ConfigEnumPair<E> (&list)[N],
MgmtByte &value)
-{
- return http_config_enum_search(ts::StringView(key), list, value);
-}
-
/// Read a string from the configuration and convert it to an enumeration
value.
/// @a n is the number of entries in the list.
/// @return @c true if the string is found, @c false if not found.
@@ -112,95 +101,6 @@ http_config_enum_read(const char *name, const
ConfigEnumPair<T> (&list)[N], Mgmt
return false;
}
-/** Create a functor that converts record data to a @c MgmtByte based on a set
of enum pairs.
- The functor takes a refernce to the byte and the record data and updates
the byte if valid.
- @return @c true if the data was valid and @a b update. @c false otherwise.
- */
-template <typename E, int N>
-MgmtByteEnumConversion
-CreateMgmtByteEnumConversion(const ConfigEnumPair<E> (&pairs)[N])
-{
- return [pairs](MgmtByte &b, const char *name, RecDataT type, RecEnumData
data) -> bool {
- MgmtByte value;
- bool valid_p = false;
- if (RECD_INT == type) {
- value = data._i;
- valid_p = std::numeric_limits<E>::min() <= value && value <=
std::numeric_limits<E>::max();
- if (!valid_p)
- Warning("Configuration update for '%s' failed - %d is not in
[%d..%d]", name, static_cast<int>(data._i),
- static_cast<int>(std::numeric_limits<E>::min()),
static_cast<int>(std::numeric_limits<E>::max()));
- } else if (RECD_STRING == type) {
- valid_p = http_config_enum_search(data._s, pairs, value);
- if (!valid_p) {
- char buff[1024];
- char *s = buff;
- char *limit = buff + sizeof(buff);
- for (auto const &p : pairs) {
- if (s + p._key.size() + 2 < limit) {
- if (s != buff)
- *s++ = ',';
- memcpy(s, p._key.ptr(), p._key.size());
- s += p._key.size();
- *s = 0;
- } else {
- break; // out of space, give up.
- }
- }
- Warning("Configuration update for '%s' failed - '%.*s' is not one of
(%s)", name, static_cast<int>(data._s.size()),
- data._s.ptr(), buff);
- }
- } else {
- Warning("Configuration update for '%s' failed - type %d - expected
STRING or INT", name, static_cast<int>(type));
- }
- if (valid_p)
- b = value;
- return valid_p;
- };
-}
-
-// forward declare for the enum update.
-static int http_config_cb(const char *, RecDataT, RecData, void *);
-
-namespace
-{
-/// Type of function called from the generic HTTP config update callback.
-/// It validates the updated data and if valid, updates the data and returns
@c true.
-using UpdateFunc = std::function<bool(const char *name, RecDataT type, RecData
data)>;
-
-/** Establish an update callback for an enum value in the same manner as the
base types.
-
- This uses the generic update callback, passing it an update functor
specialized for this
- type. When the generic update (@c http_config_cb) is called it will be
passed a pointer to the
- specialized update functor, which it will then invoke. If that succeeds,
then the data was valid
- and the override member was updated just as for the base type callbacks.
-
- A conversion functor must be supplied. See @c MgmtByteEnumConversion.
- */
-void
-HttpEstablishStaticConfigEnumByte(MgmtByte &b, const char *name,
MgmtByteEnumConversion &convertor)
-{
- // Memory management troubles. Because the callback system isn't really C++
it doesn't handle
- // cleaning up the callback data. That must be done here by stuffing the
functor into a list and
- // letting the list destructor clean up. This is not strictly needed as
these objects have process
- // lifetime and we could just "leak", but the ASAN guys will yell at me if I
do that.
- static std::list<UpdateFunc> f_list;
-
- // Create the actual update function which updates the value in the master
overide global.
- f_list.emplace_front([&b, &convertor](const char *name, RecDataT type,
RecData data) -> bool {
- return convertor(b, name, type, RecEnumData(type, data));
- });
- // Get a direct reference to it to capture in the initial update lambda.
- UpdateFunc &f = *(f_list.begin());
-
- // No standard config link because it's not a standard type.
- // Just use the generic callback with the updater.
- REC_RegisterConfigUpdateFunc(name, http_config_cb, &f);
- // Need to do this the first time around to initialize. Find the record and
whatever
- // data it has and pass that as if it were an update.
- RecLookupRecord(name, [&f](const RecRecord *r) -> void { f(r->name,
r->data_type, r->data); });
-}
-}
-
////////////////////////////////////////////////////////////////
//
// static variables
@@ -217,18 +117,12 @@ static const
ConfigEnumPair<TSServerSessionSharingPoolType> SessionSharingPoolSt
{TS_SERVER_SESSION_SHARING_POOL_GLOBAL, "global"},
{TS_SERVER_SESSION_SHARING_POOL_THREAD, "thread"}};
-static const ConfigEnumPair<TSViaTransportVerbosity>
ViaTransportVerbosityStrings[] = {{TS_VIA_TRANSPORT_NONE, "none"},
-
{TS_VIA_TRANSPORT_COMPACT, "compact"},
-
{TS_VIA_TRANSPORT_FULL, "full"}};
-
int HttpConfig::m_id = 0;
HttpConfigParams HttpConfig::m_master;
static volatile int http_config_changes = 1;
static HttpConfigCont *http_config_cont = nullptr;
-MgmtByteEnumConversion
ViaTransportVerbosityConversion{CreateMgmtByteEnumConversion(ViaTransportVerbosityStrings)};
-
HttpConfigCont::HttpConfigCont() : Continuation(new_ProxyMutex())
{
SET_HANDLER(&HttpConfigCont::handle_event);
@@ -244,22 +138,14 @@ HttpConfigCont::handle_event(int /* event ATS_UNUSED */,
void * /* edata ATS_UNU
}
static int
-http_config_cb(const char *name, RecDataT data_type, RecData data, void
*cookie)
+http_config_cb(const char * /* name ATS_UNUSED */, RecDataT /* data_type
ATS_UNUSED */, RecData /* data ATS_UNUSED */,
+ void * /* cookie ATS_UNUSED */)
{
- // A cookie means a specialized update function for this particular config
value.
- // Indirect through this because the config update logic only takes function
pointers
- // not generic functors. The update function verifies it's worth doing an
update.
- if (cookie) {
- if (!((*static_cast<UpdateFunc *>(cookie))(name, data_type, data)))
- return 0; // invalid data, don't update config.
- }
-
ink_atomic_increment((int *)&http_config_changes, 1);
INK_MEMORY_BARRIER;
eventProcessor.schedule_in(http_config_cont, HRTIME_SECONDS(1), ET_CALL);
-
return 0;
}
@@ -1052,11 +938,6 @@ HttpConfig::startup()
c.oride.server_session_sharing_match);
http_config_enum_read("proxy.config.http.server_session_sharing.pool",
SessionSharingPoolStrings, c.server_session_sharing_pool);
- HttpEstablishStaticConfigEnumByte(c.oride.request_via_transport,
"proxy.config.http.request_via_transport",
- ViaTransportVerbosityConversion);
- HttpEstablishStaticConfigEnumByte(c.oride.response_via_transport,
"proxy.config.http.response_via_transport",
- ViaTransportVerbosityConversion);
-
HttpEstablishStaticConfigByte(c.oride.auth_server_session_private,
"proxy.config.http.auth_server_session_private");
HttpEstablishStaticConfigByte(c.oride.keep_alive_post_out,
"proxy.config.http.keep_alive_post_out");
@@ -1295,8 +1176,6 @@ HttpConfig::reconfigure()
params->oride.insert_request_via_string =
m_master.oride.insert_request_via_string;
params->oride.insert_response_via_string =
m_master.oride.insert_response_via_string;
- params->oride.request_via_transport =
m_master.oride.request_via_transport;
- params->oride.response_via_transport =
m_master.oride.response_via_transport;
params->proxy_request_via_string =
ats_strdup(m_master.proxy_request_via_string);
params->proxy_request_via_string_len =
(params->proxy_request_via_string) ? strlen(params->proxy_request_via_string) :
0;
params->proxy_response_via_string =
ats_strdup(m_master.proxy_response_via_string);
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index 80a67d3..a1be533 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -47,7 +47,6 @@
#include "HttpProxyAPIEnums.h"
#include "ProxyConfig.h"
#include "P_RecProcess.h"
-#include <functional>
/* Instead of enumerating the stats in DynamicStats.h, each module needs
to enumerate its stats separately and register them with librecords
@@ -554,8 +553,6 @@ struct OverridableHttpConfigParams {
MgmtByte insert_request_via_string;
MgmtByte insert_response_via_string;
- MgmtByte request_via_transport = TS_VIA_TRANSPORT_COMPACT; ///< Verbosity
of the transport via entry for a request.
- MgmtByte response_via_transport = TS_VIA_TRANSPORT_COMPACT; ///< Verbosity
of the transport via entry for a response.
//////////////////////
// DOC IN CACHE NO DNS//
@@ -883,26 +880,4 @@ inline HttpConfigParams::~HttpConfigParams()
delete connect_ports;
}
}
-
-/// A variant of RecData that contains a StringView. This is necessary because
the TS API passes in configuration
-/// strings by pointer&length.
-union RecEnumData {
- int _i;
- ts::StringView _s;
-
- RecEnumData() : _i(0) {}
- RecEnumData(RecDataT t, RecData d)
- {
- if (t == RECD_INT)
- _i = d.rec_int;
- else if (t == RECD_STRING)
- _s = ts::StringView{d.rec_string};
- else
- _i = 0;
- }
-};
-/// Type of function called from the generic HTTP config update callback.
-/// It validates the updated data and if valid, updates the data and returns
@c true.
-using MgmtByteEnumConversion = std::function<bool(MgmtByte &b, const char
*name, RecDataT type, RecEnumData data)>;
-
#endif /* #ifndef _HttpConfig_h_ */
diff --git a/proxy/http/HttpProxyAPIEnums.h b/proxy/http/HttpProxyAPIEnums.h
index ab88b7b..f8ff3b4 100644
--- a/proxy/http/HttpProxyAPIEnums.h
+++ b/proxy/http/HttpProxyAPIEnums.h
@@ -30,10 +30,6 @@
#ifndef _HTTP_PROXY_API_ENUMS_H_
#define _HTTP_PROXY_API_ENUMS_H_
-#ifdef __cplusplus
-#include <limits>
-#endif
-
/// Server session sharing values - match
typedef enum {
TS_SERVER_SESSION_SHARING_MATCH_NONE,
@@ -48,27 +44,4 @@ typedef enum {
TS_SERVER_SESSION_SHARING_POOL_THREAD,
} TSServerSessionSharingPoolType;
-/// The verbosity of the transport protocol stack in a VIA header.
-typedef enum { TS_VIA_TRANSPORT_NONE = 0, TS_VIA_TRANSPORT_COMPACT = 1,
TS_VIA_TRANSPORT_FULL = 2 } TSViaTransportVerbosity;
-
-#ifdef __cplusplus
-namespace std
-{
-template <> class numeric_limits<TSViaTransportVerbosity> : public
numeric_limits<uint8_t>
-{
-public:
- static TSViaTransportVerbosity
- min()
- {
- return TS_VIA_TRANSPORT_NONE;
- }
- static TSViaTransportVerbosity
- max()
- {
- return TS_VIA_TRANSPORT_FULL;
- }
-};
-}
-#endif
-
#endif // _HTTP_PROXY_API_ENUMS_H_
diff --git a/proxy/http/HttpTransactHeaders.cc
b/proxy/http/HttpTransactHeaders.cc
index 3f7f583..159ad86 100644
--- a/proxy/http/HttpTransactHeaders.cc
+++ b/proxy/http/HttpTransactHeaders.cc
@@ -32,6 +32,7 @@
#include "I_Machine.h"
#include <array>
+#include <ts/MemView.h>
bool
HttpTransactHeaders::is_method_cacheable(const HttpConfigParams
*http_config_param, const int method)
@@ -684,26 +685,26 @@
HttpTransactHeaders::insert_server_header_in_response(const char *server_tag, in
}
/// write the protocol stack to the @a via_string.
+/// If @a detailed then do the full stack, otherwise just the "top level"
protocol.
size_t
-write_via_protocol_stack(char *via_string, size_t len, TSViaTransportVerbosity
detail, ts::StringView *proto_buf, int nproto)
+write_via_protocol_stack(char *via_string, size_t len, bool detailed,
ts::StringView *proto_buf, int n_proto)
{
char *via = via_string; // keep original pointer for size computation
later.
char *limit = via_string + len;
static constexpr ts::StringView tls_prefix{"tls/", ts::StringView::literal};
- if (nproto <= 0 || via == nullptr || len <= 0) {
+ if (n_proto <= 0 || via == nullptr || len <= 0) {
// nothing
- } else if (detail == TS_VIA_TRANSPORT_FULL) {
- ts::StringView *v = proto_buf;
- for (int i = 0; i < nproto && (via + v->size() + 1) < limit; ++i, ++v) {
- if (i)
- *via++ = '-';
+ } else if (detailed) {
+ for (ts::StringView *v = proto_buf, *v_limit = proto_buf + n_proto; v <
v_limit && (via + v->size() + 1) < limit; ++v) {
+ if (v != proto_buf) {
+ *via++ = ' ';
+ }
memcpy(via, v->ptr(), v->size());
via += v->size();
}
- *via++ = ' ';
- } else if (detail == TS_VIA_TRANSPORT_COMPACT) {
- ts::StringView *proto_end = proto_buf + nproto;
+ } else {
+ ts::StringView *proto_end = proto_buf + n_proto;
bool http_1_0_p = std::find(proto_buf, proto_end,
IP_PROTO_TAG_HTTP_1_0) != proto_end;
bool http_1_1_p = std::find(proto_buf, proto_end,
IP_PROTO_TAG_HTTP_1_1) != proto_end;
@@ -731,36 +732,6 @@ write_via_protocol_stack(char *via_string, size_t len,
TSViaTransportVerbosity d
return via - via_string;
}
-/// Look up the protocol stack and write it to the @a via_string.
-size_t
-write_client_protocol_stack(char *via_string, size_t len, HttpTransact::State
*s)
-{
- std::array<ts::StringView, 10> proto_buf; // 10 seems like a reasonable
number of protos to print
- int n = s->state_machine->populate_client_protocol(proto_buf.data(),
proto_buf.size());
- return write_via_protocol_stack(via_string, len,
static_cast<TSViaTransportVerbosity>(s->txn_conf->request_via_transport),
- proto_buf.data(), n);
-}
-
-/// Look up the protocol stack and write it to the @a via_string.
-size_t
-write_upstream_protocol_stack(char *via_string, size_t len,
HttpTransact::State *s, HTTPHdr *header)
-{
- int n = 0;
- int offset = 0; // # of proto_buf slots reserved
for protocol data above the netvc
- std::array<ts::StringView, 10> proto_buf; // 10 seems like a reasonable
number of protos to print
-
- // Should suffice - if we're adding a VIA, it's HTTP and only 1.0 and 1.1
are supported outbound.
- proto_buf[offset] = HTTP_MINOR(header->version_get().m_version) == 0 ?
IP_PROTO_TAG_HTTP_1_0 : IP_PROTO_TAG_HTTP_1_1;
- ++offset;
-
- auto ss = s->state_machine->get_server_session();
- if (ss) {
- n += ss->populate_protocol(proto_buf.data() + offset, proto_buf.size() -
offset);
- }
- return write_via_protocol_stack(via_string, len,
static_cast<TSViaTransportVerbosity>(s->txn_conf->response_via_transport),
- proto_buf.data(), n + offset);
-}
-
///////////////////////////////////////////////////////////////////////////////
// Name : insert_via_header_in_request
// Description: takes in existing via_string and inserts it in header
@@ -810,6 +781,7 @@
HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
{
char new_via_string[1024]; // 512-bytes for hostname+via string, 512-bytes
for the debug info
char *via_string = new_via_string;
+ char *via_limit = via_string + sizeof(new_via_string);
if ((s->http_config_param->proxy_hostname_len +
s->http_config_param->proxy_request_via_string_len) > 512) {
header->value_append(MIME_FIELD_VIA, MIME_LEN_VIA, "TrafficServer", 13,
true);
@@ -817,8 +789,10 @@
HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
}
char *incoming_via = s->via_string;
+ std::array<ts::StringView, 10> proto_buf; // 10 seems like a reasonable
number of protos to print
+ int n_proto = s->state_machine->populate_client_protocol(proto_buf.data(),
proto_buf.size());
- via_string += write_client_protocol_stack(via_string, sizeof(new_via_string)
- (via_string - new_via_string), s);
+ via_string += write_via_protocol_stack(via_string, via_limit - via_string,
false, proto_buf.data(), n_proto);
via_string += nstrcpy(via_string, s->http_config_param->proxy_hostname);
*via_string++ = '[';
@@ -843,6 +817,14 @@
HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
via_string += VIA_SERVER - VIA_CLIENT;
}
*via_string++ = ']';
+
+ // reserve 4 for " []" and 3 for "])".
+ if (via_limit - via_string > 4 && s->txn_conf->insert_request_via_string >
3) { // Ultra highest verbosity
+ *via_string++ = ' ';
+ *via_string++ = '[';
+ via_string += write_via_protocol_stack(via_string, via_limit -
via_string - 3, true, proto_buf.data(), n_proto);
+ *via_string++ = ']';
+ }
}
*via_string++ = ')';
@@ -877,6 +859,7 @@
HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH
{
char new_via_string[1024]; // 512-bytes for hostname+via string, 512-bytes
for the debug info
char *via_string = new_via_string;
+ char *via_limit = via_string + sizeof(new_via_string);
if ((s->http_config_param->proxy_hostname_len +
s->http_config_param->proxy_response_via_string_len) > 512) {
header->value_append(MIME_FIELD_VIA, MIME_LEN_VIA, "TrafficServer", 13,
true);
@@ -884,8 +867,18 @@
HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH
}
char *incoming_via = s->via_string;
+ std::array<ts::StringView, 10> proto_buf; // 10 seems like a reasonable
number of protos to print
+ int n_proto = 0;
+
+ // Should suffice - if we're adding a response VIA, the connection is HTTP
and only 1.0 and 1.1 are supported outbound.
+ proto_buf[n_proto++] = HTTP_MINOR(header->version_get().m_version) == 0 ?
IP_PROTO_TAG_HTTP_1_0 : IP_PROTO_TAG_HTTP_1_1;
+
+ auto ss = s->state_machine->get_server_session();
+ if (ss) {
+ n_proto += ss->populate_protocol(proto_buf.data() + n_proto,
proto_buf.size() - n_proto);
+ }
+ via_string += write_via_protocol_stack(via_string, via_limit - via_string,
false, proto_buf.data(), n_proto);
- via_string += write_upstream_protocol_stack(via_string,
sizeof(new_via_string) - (via_string - new_via_string), s, header);
via_string += nstrcpy(via_string, s->http_config_param->proxy_hostname);
*via_string++ = ' ';
*via_string++ = '(';
@@ -905,6 +898,13 @@
HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH
via_string += VIA_PROXY - VIA_CACHE;
}
*via_string++ = ']';
+
+ if (via_limit - via_string > 4 && s->txn_conf->insert_response_via_string
> 3) { // Ultra highest verbosity
+ *via_string++ = ' ';
+ *via_string++ = '[';
+ via_string += write_via_protocol_stack(via_string, via_limit -
via_string - 3, true, proto_buf.data(), n_proto);
+ *via_string++ = ']';
+ }
}
*via_string++ = ')';
diff --git a/tests/gold_tests/headers/via-compact.gold
b/tests/gold_tests/headers/via-compact.gold
deleted file mode 100644
index cc5518b..0000000
--- a/tests/gold_tests/headers/via-compact.gold
+++ /dev/null
@@ -1,4 +0,0 @@
-Via: http/1.1
-Via: http/1.0
-Via: https/2
-Via: https/1.1
diff --git a/tests/gold_tests/headers/via-compact.test.py
b/tests/gold_tests/headers/via-compact.test.py
deleted file mode 100644
index e1f134e..0000000
--- a/tests/gold_tests/headers/via-compact.test.py
+++ /dev/null
@@ -1,114 +0,0 @@
-'''
-Test the VIA header. This runs several requests through ATS and extracts the
upstream VIA headers.
-Those are then checked against a gold file to verify the protocol stack based
output is correct.
-'''
-# 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.
-
-import os
-import subprocess
-
-Test.Summary = '''
-Check VIA header for protocol stack data.
-'''
-
-Test.SkipUnless(
- Condition.HasATSFeature('TS_USE_TLS_ALPN'),
- Condition.HasCurlFeature('http2'),
- Condition.HasCurlFeature('IPv6')
-)
-Test.ContinueOnFail=True
-
-# Define default ATS
-ts=Test.MakeATSProcess("ts",select_ports=False)
-server=Test.MakeOriginServer("server", options={'--load' :
os.path.join(Test.TestDirectory, 'via-observer.py')})
-
-testName = "VIA"
-
-# We only need one transaction as only the VIA header will be checked.
-request_header={"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n",
"timestamp": "1469733493.993", "body": ""}
-response_header={"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n",
"timestamp": "1469733493.993", "body": ""}
-server.addResponse("sessionlog.json", request_header, response_header)
-
-# These should be promoted rather than other tests like this reaching around.
-ts.addSSLfile("../remap/ssl/server.pem")
-ts.addSSLfile("../remap/ssl/server.key")
-
-ts.Variables.ssl_port = 4443
-ts.Disk.records_config.update({
- 'proxy.config.http.insert_request_via_str' : 1,
- 'proxy.config.http.insert_response_via_str' : 1,
- 'proxy.config.http.request_via_transport' : 'compact',
- 'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir),
- 'proxy.config.ssl.server.private_key.path':
'{0}'.format(ts.Variables.SSLDir),
- 'proxy.config.http.server_ports': 'ipv4:{0}
ipv4:{1}:proto=http2;http:ssl ipv6:{0}
ipv6:{1}:proto=http2;http:ssl'.format(ts.Variables.port,ts.Variables.ssl_port),
- })
-
-ts.Disk.remap_config.AddLine(
- 'map http://www.example.com
http://127.0.0.1:{0}'.format(server.Variables.Port)
-)
-ts.Disk.remap_config.AddLine(
- 'map https://www.example.com
http://127.0.0.1:{0}'.format(server.Variables.Port,ts.Variables.ssl_port)
-)
-
-ts.Disk.ssl_multicert_config.AddLine(
- 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key'
-)
-
-# Set up to check the output after the tests have run.
-via_log_id = Test.Disk.File("via.log")
-via_log_id.Content = "via-compact.gold"
-
-# Ask the OS if the port is ready for connect()
-def CheckPort(Port) :
- return lambda : 0 == subprocess.call('netstat --listen --tcp -n | grep -q
:{}'.format(Port), shell=True)
-
-# Basic HTTP 1.1
-tr=Test.AddTestRun()
-# Wait for the micro server
-tr.Processes.Default.StartBefore(server,
ready=CheckPort(server.Variables.Port))
-# Delay on readiness of our ssl ports
-tr.Processes.Default.StartBefore(Test.Processes.ts,
ready=CheckPort(ts.Variables.ssl_port))
-
-tr.Processes.Default.Command='curl --verbose --ipv4 --http1.1 --proxy
localhost:{} http://www.example.com'.format(ts.Variables.port)
-tr.Processes.Default.ReturnCode=0
-
-tr.StillRunningAfter=server
-tr.StillRunningAfter=ts
-
-# HTTP 1.0
-tr=Test.AddTestRun()
-tr.Processes.Default.Command='curl --verbose --ipv4 --http1.0 --proxy
localhost:{} http://www.example.com'.format(ts.Variables.port)
-tr.Processes.Default.ReturnCode=0
-
-tr.StillRunningAfter=server
-tr.StillRunningAfter=ts
-
-# HTTP 2
-tr=Test.AddTestRun()
-tr.Processes.Default.Command='curl --verbose --ipv4 --insecure --header "Host:
www.example.com" https://localhost:{}'.format(ts.Variables.ssl_port)
-tr.Processes.Default.ReturnCode=0
-
-tr.StillRunningAfter=server
-tr.StillRunningAfter=ts
-
-# TLS
-tr=Test.AddTestRun()
-tr.Processes.Default.Command='curl --verbose --ipv4 --http1.1 --insecure
--header "Host: www.example.com"
https://localhost:{}'.format(ts.Variables.ssl_port)
-tr.Processes.Default.ReturnCode=0
-
-tr.StillRunningAfter=server
-tr.StillRunningAfter=ts
diff --git a/tests/gold_tests/headers/via-observer.py
b/tests/gold_tests/headers/via-observer.py
index 53ca981..3a7736f 100644
--- a/tests/gold_tests/headers/via-observer.py
+++ b/tests/gold_tests/headers/via-observer.py
@@ -20,15 +20,15 @@ Extract the protocol information from the VIA headers and
store it in a log file
import re
log = open('via.log', 'w')
-rxp = re.compile('(^.*) [\w._-]+\[.*$')
+rxp = re.compile('(\S+)\s+(\S+)\s\((\S+)\s+\[([^]]+)\]\s\[([^]]+)\]\s*\)')
def observe(headers):
if 'via' in headers:
via = headers['via']
if via:
- via = rxp.sub(r'\1', via)
+ via = rxp.sub(r'\1 = \5', via)
else:
- via = ''
+ via = '---empty---'
else:
via = '---missing---'
log.write("Via: {}\n".format(via))
diff --git a/tests/gold_tests/headers/via.gold
b/tests/gold_tests/headers/via.gold
index 9f12e56..598ef37 100644
--- a/tests/gold_tests/headers/via.gold
+++ b/tests/gold_tests/headers/via.gold
@@ -1,6 +1,6 @@
-Via: http/1.1-tcp-ipv4
-Via: http/1.0-tcp-ipv4
-Via: http/1.1-h2-tls/1.2-tcp-ipv4
-Via: http/1.1-tls/1.2-tcp-ipv4
-Via: http/1.1-tcp-ipv6
-Via: http/1.1-tls/1.2-tcp-ipv6
+Via: http/1.1 = http/1.1 tcp ipv4
+Via: http/1.0 = http/1.0 tcp ipv4
+Via: https/2 = http/1.1 h2 tls/1.2 tcp ipv4
+Via: https/1.1 = http/1.1 tls/1.2 tcp ipv4
+Via: http/1.1 = http/1.1 tcp ipv6
+Via: https/1.1 = http/1.1 tls/1.2 tcp ipv6
diff --git a/tests/gold_tests/headers/via.test.py
b/tests/gold_tests/headers/via.test.py
index f2b75e6..b9b10f3 100644
--- a/tests/gold_tests/headers/via.test.py
+++ b/tests/gold_tests/headers/via.test.py
@@ -26,10 +26,10 @@ Check VIA header for protocol stack data.
'''
Test.SkipUnless(
- Condition.HasATSFeature('TS_USE_TLS_ALPN'),
- Condition.HasCurlFeature('http2'),
- Condition.HasCurlFeature('IPv6')
-)
+ Condition.HasATSFeature('TS_USE_TLS_ALPN'),
+ Condition.HasCurlFeature('http2'),
+ Condition.HasCurlFeature('IPv6')
+)
Test.ContinueOnFail=True
# Define default ATS
@@ -49,9 +49,8 @@ ts.addSSLfile("../remap/ssl/server.key")
ts.Variables.ssl_port = 4443
ts.Disk.records_config.update({
- 'proxy.config.http.insert_request_via_str' : 1,
- 'proxy.config.http.insert_response_via_str' : 1,
- 'proxy.config.http.request_via_transport' : 'full',
+ 'proxy.config.http.insert_request_via_str' : 4,
+ 'proxy.config.http.insert_response_via_str' : 4,
'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir),
'proxy.config.ssl.server.private_key.path':
'{0}'.format(ts.Variables.SSLDir),
'proxy.config.http.server_ports': 'ipv4:{0}
ipv4:{1}:proto=http2;http:ssl ipv6:{0}
ipv6:{1}:proto=http2;http:ssl'.format(ts.Variables.port,ts.Variables.ssl_port),
@@ -125,4 +124,4 @@ tr.Processes.Default.Command='curl --verbose --ipv6
--http1.1 --insecure --heade
tr.Processes.Default.ReturnCode=0
tr.StillRunningAfter=server
-tr.StillRunningAfter=ts
\ No newline at end of file
+tr.StillRunningAfter=ts
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].