[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Module to load and save Mozilla-format cookies.txt file?
- From: PA <petite.abeille@...>
- Date: Mon, 5 Nov 2007 20:25:34 +0100
On Nov 05, 2007, at 19:59, Matt Campbell wrote:
Has anyone written a Lua module that can parse a Mozilla-format
cookies.txt file into a data structure of some kind, and generate a
cookies.txt file from a data structure of the same form? I'd like
something similar to the cookielib module shipped with Python 2.4 and
later.
Something like this perhaps?
http://dev.alt.textdrive.com/browser/HTTP/HTTPExtra.lua#L247
local Data = require( 'Data' )
local HTTPExtra = require( 'HTTPExtra' )
local HTTPCookie = require( 'HTTPCookie' )
local aCookie = HTTPCookie( '$Version="1"; Customer="WILE_E_COYOTE";
$Path="/acme"; Part_Number="Rocket_Launcher_0001";
$Path="/acme";Shipping="FedEx"; $Path="/acme"' )
print( Data( aCookie ) )
_["customer"]={}
_["customer"]["value"]="WILE_E_COYOTE"
_["customer"]["option"]={}
_["customer"]["option"]["path"]="/acme"
_["part_number"]={}
_["part_number"]["value"]="Rocket_Launcher_0001"
_["part_number"]["option"]={}
_["part_number"]["option"]["path"]="/acme"
_["shipping"]={}
_["shipping"]["value"]="FedEx"
_["shipping"]["option"]={}
_["shipping"]["option"]["path"]="/acme"
The HTTPCookie code is based on Xavante's Cookies module:
http://luaforge.net/plugins/scmcvs/cvsweb.php/~checkout~/xavante/src/
codeweb/cookies.lua?rev=1.1;content-type=text%2Fplain;cvsroot=xavante
Which itself is inspired by CGILua cookies:
http://luaforge.net/plugins/scmcvs/cvsweb.php/~checkout~/cgilua/src/
cgilua/cookies.lua?rev=1.7;content-type=text%2Fplain;cvsroot=cgilua