# HG changeset patch # User Tobias Markmann # Date 1286568579 -3600 # Node ID bd2b1836f0ba2cfea815c2bfc6568f02c268ae3c # Parent 0cfca30f1ce3e76d413bd86286469ff69370200f Add :compression() connection method to get the compression method in use (if any) diff -r 0cfca30f1ce3 -r bd2b1836f0ba src/ssl.c --- a/src/ssl.c Sat Jul 24 20:10:15 2010 +0100 +++ b/src/ssl.c Fri Oct 08 21:09:39 2010 +0100 @@ -356,6 +356,22 @@ return 1; } +/** + * Return the compression method used. + */ +static int meth_compression(lua_State *L) +{ + const COMP_METHOD *comp; + p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection"); + comp = SSL_get_current_compression(ssl->ssl); + if (comp) { + lua_pushstring(L, SSL_COMP_get_name(comp)); + return 1; + } else { + lua_pushboolean(L, 0); + return 1; + } +} /*---------------------------------------------------------------------------*/ @@ -363,15 +379,16 @@ * SSL metamethods */ static luaL_Reg meta[] = { - {"close", meth_close}, - {"getfd", meth_getfd}, - {"dirty", meth_dirty}, - {"dohandshake", meth_handshake}, - {"receive", meth_receive}, - {"send", meth_send}, - {"settimeout", meth_settimeout}, - {"want", meth_want}, - {NULL, NULL} + {"close", meth_close}, + {"getfd", meth_getfd}, + {"dirty", meth_dirty}, + {"dohandshake", meth_handshake}, + {"receive", meth_receive}, + {"send", meth_send}, + {"settimeout", meth_settimeout}, + {"want", meth_want}, + {"compression", meth_compression}, + {NULL, NULL} }; /**