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
commit 313ba1d306104e1c277e98cbd46072ada9f817ba Author: Daniel Morilha (netlify) <[email protected]> AuthorDate: Mon Nov 5 12:49:51 2018 -0800 adding TSHttpTxnRedoCacheLookup --- include/ts/experimental.h | 1 + proxy/http/HttpSM.cc | 10 ++++++++++ proxy/http/HttpSM.h | 2 ++ src/traffic_server/InkAPI.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/include/ts/experimental.h b/include/ts/experimental.h index fa8e7ea..a1bab6f 100644 --- a/include/ts/experimental.h +++ b/include/ts/experimental.h @@ -198,6 +198,7 @@ tsapi TSReturnCode TSHttpTxnCacheLookupCountGet(TSHttpTxn txnp, int *lookup_coun tsapi TSReturnCode TSHttpTxnServerRespIgnore(TSHttpTxn txnp); tsapi TSReturnCode TSHttpTxnShutDown(TSHttpTxn txnp, TSEvent event); tsapi TSReturnCode TSHttpTxnCloseAfterResponse(TSHttpTxn txnp, int should_close); +tsapi void TSHttpTxnRedoCacheLookup(TSHttpTxn txnp, const char *, const int, const char *, const char *); /**************************************************************************** * ?? diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 793b82f..e9398c7 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -1511,6 +1511,11 @@ plugins required to work with sni_routing. case HTTP_API_DEFERED_SERVER_ERROR: api_next = API_RETURN_DEFERED_SERVER_ERROR; break; + case HTTP_API_REWIND_STATE_MACHINE: + DebugSM("http", "REWIND"); + callout_state = HTTP_API_NO_CALLOUT; + set_next_state(); + return 0; default: ink_release_assert(0); } @@ -8027,6 +8032,11 @@ HttpSM::find_proto_string(HTTPVersion version) const return {}; } +void +HttpSM::rewind_state_machine() { + callout_state = HTTP_API_REWIND_STATE_MACHINE; +} + // YTS Team, yamsat Plugin // Function to copy the partial Post data while tunnelling void diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h index 748d307..931c725 100644 --- a/proxy/http/HttpSM.h +++ b/proxy/http/HttpSM.h @@ -155,6 +155,7 @@ enum HttpApiState_t { HTTP_API_IN_CALLOUT, HTTP_API_DEFERED_CLOSE, HTTP_API_DEFERED_SERVER_ERROR, + HTTP_API_REWIND_STATE_MACHINE, }; enum HttpPluginTunnel_t { @@ -615,6 +616,7 @@ public: void set_server_netvc_inactivity_timeout(NetVConnection *netvc); void set_server_netvc_active_timeout(NetVConnection *netvc); void set_server_netvc_connect_timeout(NetVConnection *netvc); + void rewind_state_machine(); private: PostDataBuffers _postbuf; diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index b61fdc0..88389cd 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -9789,6 +9789,52 @@ TSRegisterProtocolTag(const char *tag) return nullptr; } +void +TSHttpTxnRedoCacheLookup(TSHttpTxn txnp, const char * host, const int port, + const char * path, const char * query) +{ + sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); + HttpSM *sm = (HttpSM *)txnp; + HttpTransact::State * s = &(sm->t_state); + sdk_assert(s->next_action == HttpTransact::SM_ACTION_CACHE_LOOKUP); + s->transact_return_point = nullptr; + + sm->rewind_state_machine(); + + TSMBuffer buffer = nullptr; + TSMLoc location = nullptr, location2 = nullptr; + + TSHttpTxnClientReqGet(txnp, &buffer, &location); + TSHttpHdrUrlGet(buffer, location, &location2); + + //host + if (nullptr != host) { + const int length = strlen(host); + TSUrlHostSet(buffer, location2, host, length); + } + + //port + if (0 < port) { + TSUrlPortSet(buffer, location2, port); + } + + //path + if (nullptr != path) { + const int length = strlen(path); + TSUrlPathSet(buffer, location2, path, length); + } + + //query + if (nullptr != query) { + const int length = strlen(query); + TSUrlHttpQuerySet(buffer, location2, query, length); + } + + TSHandleMLocRelease(buffer, location, location2); + TSHandleMLocRelease(buffer, TS_NULL_MLOC, location); +} + + namespace { // Function that contains the common logic for TSRemapFrom/ToUrlGet().
