From 7d9d62685fa141bacc34e795386ef567aa574ecb Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 30 Nov 2010 01:21:57 +0100 Subject: Making cookies working properly, where they are more than one. --- lib/HttpServ.cc | 6 ++---- lib/httplib.lua | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index 2e1779b..7b757a9 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -915,11 +915,9 @@ void HttpResponse::PrepareResponse(Handle * b) { strftime(buf, 1024, "%a, %d %b %Y %H:%M:%S GMT", ft); (*b) << "Last-Modified: " << buf << "\r\n"; } - if (cookies.size()) { + for (std::vector >::iterator i = cookies.begin(); i != cookies.end(); i++) { (*b) << "Set-Cookie: "; - for (std::vector >::iterator i = cookies.begin(); i != cookies.end(); i++) { - (*b) << i->first << "=" << i->second << ";"; - } + (*b) << i->first << "=" << i->second << ";"; if (cookies_path != "") (*b) << "path=" << cookies_path; (*b) << "\r\n"; diff --git a/lib/httplib.lua b/lib/httplib.lua index 42c42a6..26d66bd 100644 --- a/lib/httplib.lua +++ b/lib/httplib.lua @@ -59,8 +59,8 @@ function get_cookies(req) local k, v for k, v in pairs(cookie_strings) do - local cname, cvalue = string.match(v, "(%w+)=(.+)") - cookies[cname] = cvalue + local cname, cvalue = string.match(v, "(%[^=]+)=(.+)") + if cname then cookies[trim(cname)] = trim(cvalue) end end end return cookies -- cgit v1.2.3