summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/LuaHttp.cc35
1 files changed, 25 insertions, 10 deletions
diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc
index 89e55e7..dd2e74d 100644
--- a/lib/LuaHttp.cc
+++ b/lib/LuaHttp.cc
@@ -135,11 +135,11 @@ 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 | BLUA_OBJECT} },
+ { 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 } },
- { HTTPRESPONSE_SHA256, "SHA256", 1, 1, { BLUA_STRING } },
+ { HTTPRESPONSE_MD5, "MD5", 1, 1, { BLUA_STRING | BLUA_OBJECT } },
+ { HTTPRESPONSE_SHA1, "SHA1", 1, 1, { BLUA_STRING | BLUA_OBJECT } },
+ { HTTPRESPONSE_SHA256, "SHA256", 1, 1, { BLUA_STRING | BLUA_OBJECT } },
{ HTTPRESPONSE_GENTICKET, "GenTicket", 0, 1, { BLUA_NUMBER } },
{ -1, 0, 0, 0, 0 }
};
@@ -322,29 +322,44 @@ int sLua_HttpResponse::HttpResponse_proceed_statics(Lua * L, int n, int caller)
break;
case HTTPRESPONSE_MD5:
- dec = L->tostring();
- {
+ if (L->isstring()) {
+ dec = L->tostring();
MD5 h;
h.Update(dec);
L->push(h.Finish());
+ } else {
+ Handle * hdata = (Handle *) LuaObject::getme(L, 1);
+ MD5 h;
+ h.Update(hdata);
+ L->push(h.Finish());
}
r = 1;
break;
case HTTPRESPONSE_SHA1:
- dec = L->tostring();
- {
+ if (L->isstring()) {
+ dec = L->tostring();
SHA1 h;
h.Update(dec);
L->push(h.Finish());
+ } else {
+ Handle * hdata = (Handle *) LuaObject::getme(L, 1);
+ SHA1 h;
+ h.Update(hdata);
+ L->push(h.Finish());
}
r = 1;
break;
case HTTPRESPONSE_SHA256:
- dec = L->tostring();
- {
+ if (L->isstring()) {
+ dec = L->tostring();
SHA256 h;
h.Update(dec);
L->push(h.Finish());
+ } else {
+ Handle * hdata = (Handle *) LuaObject::getme(L, 1);
+ SHA256 h;
+ h.Update(hdata);
+ L->push(h.Finish());
}
r = 1;
break;