You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by James Peach <jp...@apache.org> on 2016/08/05 02:28:06 UTC

Re: TSHttpTxnIsWebsocket API function

> On Jul 28, 2016, at 7:38 PM, James Peach <jp...@apache.org> wrote:
> 
>> 
>> On Jul 24, 2016, at 11:08 PM, Oliver Goodman <oa...@optusnet.com.au> wrote:
>> 
>> JIRA issue TS-4698 and pull request https://github.com/apache/trafficserver/pull/822 propose to add a TS API function to determine whether the current client request represents a websocket connection attempt.
>> 
>> The motivation: I’ve been working on a C++ API intercept plugin which, among other things, is able to terminate websocket connections. I thought it might be of interest to contribute a websocket termination example (see TS-4699 and the associated pull request https://github.com/apache/trafficserver/pull/824).
>> 
>> In order for such a plugin to determine whether the incoming connection is a websocket connection it seems appropriate that
>> * it use the same test that TS already uses internally to make this decision, and that
>> * the ‘official correct way’ to make this decision be exposed through an API function.
>> 
>> For this purpose I’m proposing to add a function called TSHttpTxnIsWebsocket. It takes a TSHttpTxn and returns a C int, to be interpreted as a bool in the standard C way, namely non-zero means true.
> 
> Thanks Oliver. This API looks OK to me, I haven’t reviewed the documentation yet, but we should make sure to be clear when in the state machine this API will return valid results.
> 
> Can we get consensus on whether this should return “int” or “TSReturnCode”?
> 
> jpeach$ grep 'TS.*Is.*' proxy/api/ts/ts.h
> tsapi int TSVConnIsSsl(TSVConn sslp);
> /** @deprecated to be renamed as TSHttpTxnIsInternal **/
> tsapi TS_DEPRECATED TSReturnCode TSHttpIsInternalRequest(TSHttpTxn txnp);
> /** @deprecated to be renamed as TSHttpSsnIsInternal **/
> tsapi TS_DEPRECATED TSReturnCode TSHttpIsInternalSession(TSHttpSsn ssnp);
> tsapi TSReturnCode TSHttpTxnIsInternal(TSHttpTxn txnp);
> tsapi TSReturnCode TSHttpSsnIsInternal(TSHttpSsn ssnp);
> tsapi int TSIsDebugTagSet(const char *t);
> tsapi int TSHttpTxnIsCacheable(TSHttpTxn txnp, TSMBuffer request, TSMBuffer response);
> 
> TSHttpSsnIsInternal is the most recent so I think we should prefer TSReturnCode for new code?

OK, we are going to prefer TSReturnCode for these APIs. I’ll review the PR again next week and land this soon after. Thanks Oliver.

J