diff options
author | pixel <pixel> | 2008-07-16 16:50:24 +0000 |
---|---|---|
committer | pixel <pixel> | 2008-07-16 16:50:24 +0000 |
commit | d1d512080aafbf9a271c13cd3eb04815baeebadc (patch) | |
tree | 999acff041d17618f02cd1b066477d87da6afa2b /lib/LuaHttp.cc | |
parent | 5627c9a50ada2bce7c43c7bdeefe822c2b53df61 (diff) |
Adding basic cookies support.
Diffstat (limited to 'lib/LuaHttp.cc')
-rw-r--r-- | lib/LuaHttp.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/LuaHttp.cc b/lib/LuaHttp.cc index 0f2bd70..8284537 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.27 2008-02-26 18:23:58 pixel Exp $ */ +/* $Id: LuaHttp.cc,v 1.28 2008-07-16 16:50:24 pixel Exp $ */ #include "Domain.h" #include "LuaHttp.h" @@ -220,6 +220,10 @@ int sLua_HttpResponse::HttpResponse_proceed(Lua * L, int n, HttpResponse * res, } } else if (i == "cache") { L->push(res->cache); + } else if (i == "cookies_path") { + L->push(res->cookies_path); + } else if (i == "cookies") { + L->error("Can't read cookies (for now)"); } else { L->error("Unknow field in HttpResponse object: " + i); } @@ -245,6 +249,18 @@ int sLua_HttpResponse::HttpResponse_proceed(Lua * L, int n, HttpResponse * res, L->error("Can't alter field buffer in HttpResponse."); } else if (i == "cache") { res->cache = L->toboolean(3); + } else if (i == "cookies_path") { + res->cookies_path = L->tostring(3); + } else if (i == "cookies") { + String cookie = L->tostring(3), key, value; + int pos = cookie.strchr('='); + if (pos < 0) { + L->error("Malformed cookie."); + } + key = cookie.extract(0, pos - 1).trim(); + value = cookie.extract(pos + 1).trim(); + std::pair<String, String> e(key, value); + res->cookies.push_back(e); } else { L->error("Unknow field in HttpResponse object: " + i); } @@ -325,7 +341,7 @@ int sLua_HttpResponse::HttpResponse_proceed_statics(Lua * L, int n, int caller) } LuaDomain::LuaDomain(Lua * _L, String r) : Domain(r), L(_L->Father()) { - id = max_id++; + id = max_id++; /***FIXME***/ L->push(DOMAIN_REGISTRY); L->gettable(LUA_REGISTRYINDEX); |