diff options
author | pixel <pixel> | 2008-02-26 18:23:58 +0000 |
---|---|---|
committer | pixel <pixel> | 2008-02-26 18:23:58 +0000 |
commit | 0be6869498b4fda7ddf1b419b2a7086c1e30bc4f (patch) | |
tree | cb66da43f3bae2adf2d52a418cca6f8644772f59 /lib | |
parent | 11d24fff6bbda7fd295b035d79da9f29725f0e1f (diff) |
Improving Base64's arguments
Diffstat (limited to 'lib')
-rw-r--r-- | lib/LuaHttp.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc index 483ef2a..0f2bd70 100644 --- a/lib/LuaHttp.cc +++ b/lib/LuaHttp.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: LuaHttp.cc,v 1.26 2008-01-28 17:30:46 pixel Exp $ */ +/* $Id: LuaHttp.cc,v 1.27 2008-02-26 18:23:58 pixel Exp $ */ #include "Domain.h" #include "LuaHttp.h" @@ -133,7 +133,7 @@ struct lua_functypes_t HttpResponse_methods[] = { struct lua_functypes_t HttpResponse_functions[] = { { HTTPRESPONSE_NEWHTTPRESPONSE, "HttpResponse", 0, 0, { } }, - { HTTPRESPONSE_BASE64_ENCODE, "Base64Encode", 1, 1, { BLUA_STRING } }, + { HTTPRESPONSE_BASE64_ENCODE, "Base64Encode", 1, 1, { BLUA_STRING | BLUA_OBJECT} }, { HTTPRESPONSE_BASE64_DECODE, "Base64Decode", 1, 1, { BLUA_STRING } }, { HTTPRESPONSE_MD5, "MD5", 1, 1, { BLUA_STRING } }, { HTTPRESPONSE_SHA1, "SHA1", 1, 1, { BLUA_STRING } }, @@ -270,16 +270,25 @@ int sLua_HttpResponse::HttpResponse_proceed_statics(Lua * L, int n, int caller) break; case HTTPRESPONSE_BASE64_ENCODE: - dec = L->tostring(); - dec_t = dec.to_charp(); - L->push(Base64::encode(dec_t, dec.strlen())); + if (L->isstring()) { + dec = L->tostring(); + dec_t = dec.to_charp(); + L->push(Base64::encode(dec_t, dec.strlen())); + } else { + Handle * hdata = (Handle *) LuaObject::getme(L, 1); + int size = hdata->GetSize(); + char * data = (char *) malloc(size); + hdata->read(data, size); + L->push(Base64::encode(data, size)); + free(data); + } r = 1; break; case HTTPRESPONSE_BASE64_DECODE: enc_t = (char *) Base64::decode(L->tostring(), &l); enc_t[l] = 0; - L->push(enc_t); + L->push(enc_t, l); r = 1; break; |