-*- coding: utf-8 -*-
Changes with Apache 2.5.0
+ *) mod_lua: Add r:wspeek for checking if there is any data waiting on the line
+ [Daniel Gruno]
+
*) mod_proxy_wstunnel: Avoid busy loop on client errors, drop message
IDs 02445, 02446, and 02448 to TRACE1 from DEBUG. PR 56145.
[Joffroy Christen <joffroy.christen solvaxis com>, Eric Covener]
end
</highlight>
+<highlight language="lua">
+r:wspeek() -- Checks if any data is ready to be read
+
+-- Sleep while nothing is being sent to us...
+while r:wspeek() == false do
+ r.usleep(50000)
+end
+-- We have data ready!
+local line = r:wsread()
+
+</highlight>
+
</section>
<section id="logging"><title>Logging Functions</title>
return rv;
}
+static int lua_websocket_peek(lua_State *L)
+{
+ apr_status_t rv;
+ apr_bucket_brigade *brigade;
+
+ request_rec *r = ap_lua_check_request_rec(L, 1);
+
+ brigade = apr_brigade_create(r->connection->pool,
+ r->connection->bucket_alloc);
+ rv = ap_get_brigade(r->connection->input_filters, brigade,
+ AP_MODE_READBYTES, APR_NONBLOCK_READ, 1);
+ if (rv == APR_SUCCESS) {
+ lua_pushboolean(L, 1);
+ }
+ else {
+ lua_pushboolean(L, 0);
+ }
+ apr_brigade_cleanup(brigade);
+ return 1;
+}
+
static int lua_websocket_read(lua_State *L)
{
apr_socket_t *sock;
makefun(&lua_websocket_greet, APL_REQ_FUNTYPE_LUACFUN, p));
apr_hash_set(dispatch, "wsread", APR_HASH_KEY_STRING,
makefun(&lua_websocket_read, APL_REQ_FUNTYPE_LUACFUN, p));
+ apr_hash_set(dispatch, "wspeek", APR_HASH_KEY_STRING,
+ makefun(&lua_websocket_peek, APL_REQ_FUNTYPE_LUACFUN, p));
apr_hash_set(dispatch, "wswrite", APR_HASH_KEY_STRING,
makefun(&lua_websocket_write, APL_REQ_FUNTYPE_LUACFUN, p));
apr_hash_set(dispatch, "wsclose", APR_HASH_KEY_STRING,