Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

TS-1058: add TSHttpTxnCloseAfterResponse experimental API

Add a new API to force the server end of a HTTP keepalive. This is
useful for a plugin that sets the error body to easuly intercept a
transaction, but needs to ensure that the subsequent request does
not go to a different replica. One example of this use case is a
challenge-response authentication protocol where the challenge data
is held in memory on the session.
  • Loading branch information...
commit 8facd16fdcb2ec5c5efd66bb8d4c9c2ba24d1231 1 parent 7016ec9
Yakov Kopel authored jpeach committed
Showing with 26 additions and 1 deletion.
  1. +5 −1 CHANGES
  2. +20 −0 proxy/InkAPI.cc
  3. +1 −0  proxy/api/ts/experimental.h
View
6 CHANGES
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 3.3.1
+
+ *) [TS-1058] add TSHttpTxnCloseAfterResponse experimental API
+ Author: Yakov Kopel <ykopel@websense.com>
+
*) [TS-1733] Retool tsxs so that it can compile multiple source files
Author: Dale Ghent <daleg@omniti.com>
@@ -10,7 +14,7 @@ Changes with Apache Traffic Server 3.3.1
*) [TS-1739] Fix TODO within varFloatFromName()
Author: Yunkai Zhang <qiushu.zyk@taobao.com>
- *) [TS-1559] Server side termination not handled properly when a PluginVC
+ *) [TS-1559] Server side termination not handled properly when a PluginVC
Protocol Plugin is used. Author: Yossi Gottlieb.
*) [TS-1300] Document the usage of TSUrlStringGet() and derivatives.
View
20 proxy/InkAPI.cc
@@ -8125,6 +8125,26 @@ TSMgmtIntCreate(TSRecordType rec_type, const char *name, TSMgmtInt data_default,
return TS_SUCCESS;
}
+TSReturnCode
+TSHttpTxnCloseAfterResponse (TSHttpTxn txnp, int should_close)
+{
+ if (sdk_sanity_check_txn(txnp)!=TS_SUCCESS) {
+ return TS_ERROR;
+ }
+
+ HttpSM *sm = (HttpSM*)txnp;
+ if (should_close) {
+ sm->t_state.client_info.keep_alive = HTTP_NO_KEEPALIVE;
+ if (sm->ua_session) sm->set_ua_half_close_flag();
+ }
+ // Don't change if PIPELINE is set...
+ else if (sm->t_state.client_info.keep_alive == HTTP_NO_KEEPALIVE) {
+ sm->t_state.client_info.keep_alive = HTTP_KEEPALIVE;
+ }
+
+ return TS_SUCCESS;
+}
+
// Parse a port descriptor for the proxy.config.http.server_ports descriptor format.
TSPortDescriptor
TSPortDescriptorParse(const char * descriptor)
View
1  proxy/api/ts/experimental.h
@@ -184,6 +184,7 @@ extern "C"
tsapi TSReturnCode TSHttpTxnCacheLookupSkip(TSHttpTxn txnp);
tsapi TSReturnCode TSHttpTxnServerRespIgnore(TSHttpTxn txnp);
tsapi TSReturnCode TSHttpTxnShutDown(TSHttpTxn txnp, TSEvent event);
+ tsapi TSReturnCode TSHttpTxnCloseAfterResponse(TSHttpTxn txnp, int should_close);
/****************************************************************************
* ??
Please sign in to comment.
Something went wrong with that request. Please try again.