From fa8a9ce1480485ad5cd1866e79792a7528eef73b Mon Sep 17 00:00:00 2001 From: Petar Penkov Date: Wed, 27 Jul 2016 19:44:30 +0000 Subject: [PATCH 1/2] TS-4703: Adds an API call to retrieve transaction protocol --- .../TSHttpTxnClientProtocolGet.en.rst | 34 +++++++++++++++++++ proxy/InkAPI.cc | 9 +++++ proxy/api/ts/ts.h | 2 ++ 3 files changed, 45 insertions(+) create mode 100644 doc/developer-guide/api/functions/TSHttpTxnClientProtocolGet.en.rst diff --git a/doc/developer-guide/api/functions/TSHttpTxnClientProtocolGet.en.rst b/doc/developer-guide/api/functions/TSHttpTxnClientProtocolGet.en.rst new file mode 100644 index 00000000000..c765afcc930 --- /dev/null +++ b/doc/developer-guide/api/functions/TSHttpTxnClientProtocolGet.en.rst @@ -0,0 +1,34 @@ +.. 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 + +.. default-domain:: c + +TSHttpTxnClientProtocolGet +********************* + +Gets the protocol string (http, http/2) of a specified transaction. + +Synopsis +======== + +`#include ` + +.. function:: const char * TSHttpTxnClientProtocolGet(TSHttpTxn txnp) + +Description +=========== diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 949d18d4ced..ce3b1912356 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -4655,6 +4655,15 @@ TSHttpTxnClientReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *obj) return TS_ERROR; } +const char * +TSHttpTxnClientProtocolGet(TSHttpTxn txnp) +{ + sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); + + HttpSM *sm = reinterpret_cast(txnp); + return sm->ua_session->get_protocol_string(); +} + // pristine url is the url before remap TSReturnCode TSHttpTxnPristineUrlGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *url_loc) diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h index 294d495739c..41977be59b4 100644 --- a/proxy/api/ts/ts.h +++ b/proxy/api/ts/ts.h @@ -1256,6 +1256,8 @@ tsapi TSReturnCode TSHttpTxnServerRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLo tsapi TSReturnCode TSHttpTxnCachedReqGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *offset); /* Gets the cached response header for a specified HTTP transaction. */ tsapi TSReturnCode TSHttpTxnCachedRespGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *offset); +/* Gets the protocol string for a specified HTTP transaction. */ +tsapi const char *TSHttpTxnClientProtocolGet(TSHttpTxn txnp); tsapi TSReturnCode TSHttpTxnPristineUrlGet(TSHttpTxn txnp, TSMBuffer *bufp, TSMLoc *url_loc); From 5152d9c2ab867c8da40b607cb377940c427b2835 Mon Sep 17 00:00:00 2001 From: Petar Penkov Date: Mon, 1 Aug 2016 21:28:20 +0000 Subject: [PATCH 2/2] TS-4703: Adds an API call to retrieve session protocol --- .../TSHttpSsnClientProtocolGet.en.rst | 34 +++++++++++++++++++ proxy/InkAPI.cc | 12 ++++++- proxy/api/ts/ts.h | 2 ++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 doc/developer-guide/api/functions/TSHttpSsnClientProtocolGet.en.rst diff --git a/doc/developer-guide/api/functions/TSHttpSsnClientProtocolGet.en.rst b/doc/developer-guide/api/functions/TSHttpSsnClientProtocolGet.en.rst new file mode 100644 index 00000000000..91a591a7814 --- /dev/null +++ b/doc/developer-guide/api/functions/TSHttpSsnClientProtocolGet.en.rst @@ -0,0 +1,34 @@ +.. 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 + +.. default-domain:: c + +TSHttpSsnClientProtocolGet +********************* + +Gets the protocol string (http, http/2) of a specified session. + +Synopsis +======== + +`#include ` + +.. function:: const char * TSHttpSsnClientProtocolGet(TSHttpSsn ssnp) + +Description +=========== diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index ce3b1912356..18655a33a84 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -4584,6 +4584,16 @@ TSHttpSsnReenable(TSHttpSsn ssnp, TSEvent event) } } +const char * +TSHttpSsnClientProtocolGet(TSHttpSsn ssnp) +{ + sdk_assert(sdk_sanity_check_http_ssn(ssnp) == TS_SUCCESS); + + ProxyClientSession *cs = reinterpret_cast(ssnp); + + return cs->get_protocol_string(); +} + /* HTTP transactions */ void TSHttpTxnHookAdd(TSHttpTxn txnp, TSHttpHookID id, TSCont contp) @@ -4661,7 +4671,7 @@ TSHttpTxnClientProtocolGet(TSHttpTxn txnp) sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); HttpSM *sm = reinterpret_cast(txnp); - return sm->ua_session->get_protocol_string(); + return sm->client_protocol; } // pristine url is the url before remap diff --git a/proxy/api/ts/ts.h b/proxy/api/ts/ts.h index 41977be59b4..54848a1a8da 100644 --- a/proxy/api/ts/ts.h +++ b/proxy/api/ts/ts.h @@ -1219,6 +1219,8 @@ tsapi void TSHttpHookAdd(TSHttpHookID id, TSCont contp); tsapi void TSHttpSsnHookAdd(TSHttpSsn ssnp, TSHttpHookID id, TSCont contp); tsapi void TSHttpSsnReenable(TSHttpSsn ssnp, TSEvent event); tsapi int TSHttpSsnTransactionCount(TSHttpSsn ssnp); +/* Gets the protocol string for a specified HTTP session. */ +tsapi const char *TSHttpSsnClientProtocolGet(TSHttpSsn ssnp); /* -------------------------------------------------------------------------- SSL connections */