trafficserver-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Goodman <...@optusnet.com.au>
Subject TSHttpTxnIsWebsocket API function
Date Sun, 24 Jul 2016 13:08:23 GMT
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.

The test checks whether the HttpSM state is_upgrade_request flag is set with an upgrade_token_wks
of MIME_VALUE_WEBSOCKET. IIUC this is equivalent to the incoming request having an upgrade
header with a value of `websocket`.

Documentation for this very simple function is in TSHttpTxnIsWebsocket.en.rst in the PR.

Cheers,
Oliver


Mime
View raw message