-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparams.json
1 lines (1 loc) · 11.5 KB
/
params.json
1
{"name":"Lua-cURL","body":"<table frame=\"void\" rules=\"none\">\r\n<col />\r\n<col />\r\n<tbody valign=\"top\">\r\n<tr><th>Previous (original) Author:</th>\r\n<td>Jürgen Hötzel</td></tr>\r\n<tr><th>Current Author:</th>\r\n<td>Vadim A. Misbakh-Soloviov</td></tr>\r\n<tr><th>Contact:</th>\r\n<td><a href=\"http://mva.name/\">http://mva.name/</a></td></tr>\r\n</tbody>\r\n</table>\r\n\r\n<div>\r\n<p><a id=\"contents\" name=\"contents\">Contents</a></p>\r\n<ul>\r\n<li><a href=\"#introduction\" id=\"id1\" name=\"id1\">Introduction</a></li>\r\n<li><a href=\"#installation\" id=\"id2\" name=\"id2\">Installation</a></li>\r\n<li><a href=\"#easy-interface\" id=\"id3\" name=\"id3\">Easy interface</a><ul>\r\n<li><a href=\"#example-1-fetch-the-example-com-homepage\" id=\"id4\" name=\"id4\">Example 1: Fetch the example.com homepage</a></li>\r\n<li><a href=\"#example-2-on-the-fly-file-upload\" id=\"id5\" name=\"id5\">Example 2: "On-The-Fly" file upload</a></li>\r\n<li><a href=\"#example-3-posting-data\" id=\"id6\" name=\"id6\">Example 3: "Posting" data</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"#multi-interface\" id=\"id7\" name=\"id7\">Multi interface</a><ul>\r\n<li><a href=\"#example-1-on-the-fly-xml-parsing\" id=\"id8\" name=\"id8\">Example 1: "On-The-Fly" XML parsing</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"#share-interface\" id=\"id9\" name=\"id9\">Share interface</a><ul>\r\n<li><a href=\"#example-1-share-cookie-date-across-easy-handles\" id=\"id10\" name=\"id10\">Example 1: Share Cookie date across easy handles</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"#appendix\" id=\"id11\" name=\"id11\">Appendix</a><ul>\r\n<li><a href=\"#using-ssl\" id=\"id12\" name=\"id12\">Using SSL</a></li>\r\n</ul>\r\n</li>\r\n</ul>\r\n</div>\r\n<div>\r\n<h1><a href=\"#id1\" id=\"introduction\" name=\"introduction\">Introduction</a></h1>\r\n<p>This project is <strong>not</strong> a fork of <a href=\"http://luaforge.net/projects/luacurl/\">LuaCURL</a>, which is a direct mapping of parts of the <a href=\"http://curl.haxx.se/libcurl/c/libcurl-easy.html\">libcurl-easy</a> interface.</p>\r\n<p>The intent of Lua-cURL is to adapt the</p>\r\n<ul>\r\n<li>Easy Interface</li>\r\n<li>Multi Interface</li>\r\n<li>Shared Interface</li>\r\n</ul>\r\n<p>of <a href=\"http://curl.haxx.se/libcurl/c/\">libcurl</a> to the functionality of Lua (for example by using iterators instead of callbacks when possible).</p>\r\n</div>\r\n<div>\r\n<h1><a href=\"#id2\" id=\"installation\" name=\"installation\">Installation</a></h1>\r\n<p>The Autotools chain is used to configure, build and install. Just invoke:</p>\r\n<pre>\r\n<code>\r\n./configure && make install\r\n</code>\r\n</pre>\r\n<p>If your Lua installation doesn't contain pkg-config support, you have to specify compiler/linker flags and the target directory:</p>\r\n<pre>\r\n<code>\r\nexport LUA_CFLAGS="-I/usr/local/include"\r\nexport LUA_LIBS="-L/usr/local/lib -lm -llua"\r\n./configure --with-cmoddir=/usr/local/lib/lua/5.1\r\n</code>\r\n</pre>\r\n</div>\r\n<div>\r\n<h1><a href=\"#id3\" id=\"easy-interface\" name=\"easy-interface\">Easy interface</a></h1>\r\n<dl>\r\n<dt><strong>cURL.easy_init()</strong></dt>\r\n<dd>returns a new easy handle.</dd>\r\n<dt><strong>cURL.version_info()</strong></dt>\r\n<dd>returns a table containing version info and features/protocols sub table</dd>\r\n<dt><strong>easy:escape(string)</strong></dt>\r\n<dd>return URL encoded string</dd>\r\n<dt><strong>easy:unescape(string)</strong></dt>\r\n<dd>return URL decoded string</dd>\r\n<dt><strong>easy:setopt*(value)</strong></dt>\r\n<dd><dl class=\"first last docutils\">\r\n<dt>libcurl properties an options are mapped to individual functions:</dt>\r\n<dd><ul class=\"first last simple\">\r\n<li><strong>easy:setopt_url(string)</strong></li>\r\n<li><strong>easy:setopt_verbose(number)</strong></li>\r\n<li><strong>easy:setopt_proxytype(string)</strong></li>\r\n<li><strong>easy:setopt_share(share)</strong> (See: <a href=\"#share\">share</a>)</li>\r\n<li>...</li>\r\n</ul>\r\n</dd>\r\n</dl>\r\n</dd>\r\n<dt><strong>easy:perform(table)</strong></dt>\r\n<dd><dl class=\"first last docutils\">\r\n<dt>Perform the transfer as described in the options, using an optional callback table.The callback table indices are named after the equivalent cURL callbacks:</dt>\r\n<dd><ul class=\"first last simple\">\r\n<li><strong>writefunction = function(str)</strong></li>\r\n<li><strong>readfunction = function()</strong></li>\r\n<li><strong>headerfunction = function(str)</strong></li>\r\n</ul>\r\n</dd>\r\n</dl>\r\n</dd>\r\n<dt><strong>easy:post(table)</strong></dt>\r\n<dd><p>Prepare a multipart/formdata post. The table indices are named after the form fields and should map to string values:</p>\r\n<pre>\r\n{field1 = value1,\r\n field2 = value1}\r\n</pre>\r\n<p>or more generic descriptions in tables:</p>\r\n<pre class=\"last literal-block\">\r\n{field1 = {file="/tmp/test.txt",\r\n type="text/plain"},\r\n{field2 = {file="dummy.html",\r\n data="<html><bold>bold</bold></html>,\r\n type="text/html"}}\r\n</pre>\r\n</dd>\r\n</dl>\r\n<div>\r\n<h2><a href=\"#id4\" id=\"example-1-fetch-the-example-com-homepage\" name=\"example-1-fetch-the-example-com-homepage\">Example 1: Fetch the example.com homepage</a></h2>\r\n<pre>\r\nrequire("cURL")\r\n\r\n-- open output file\r\nf = io.open("example_homepage", "w")\r\n\r\nc = cURL.easy_init()\r\n-- setup url\r\nc:setopt_url("http://www.example.com/")\r\n-- perform, invokes callbacks\r\nc:perform({writefunction = function(str)\r\n\t\t\t\tf:write(str)\r\n\t\t\t end})\r\n\r\n-- close output file\r\nf:close()\r\nprint("Done")\r\n</pre>\r\n</div>\r\n<div>\r\n<h2><a href=\"#id5\" id=\"example-2-on-the-fly-file-upload\" name=\"example-2-on-the-fly-file-upload\">Example 2: "On-The-Fly" file upload</a></h2>\r\n<pre>\r\n-- simple "On the fly" fileupload\r\n\r\nrequire("cURL")\r\n\r\nc=cURL.easy_init()\r\nc:setopt_url("ftp://ftptest:secret0815@targethost/file.dat")\r\nc:setopt_upload(1)\r\ncount=0\r\nc:perform({readfunction=function(n)\r\n\t\t\t count = count + 1\r\n\t\t\t if (count < 10) then\r\n\t\t\t return "Line " .. count .. "\\n"\r\n\t\t\t end\r\n\t\t\t return nil\r\n\t\t\tend})\r\nprint("Fileupload done")\r\n</pre>\r\n</div>\r\n<div>\r\n<h2><a href=\"#id6\" id=\"example-3-posting-data\" name=\"example-3-posting-data\">Example 3: "Posting" data</a></h2>\r\n<pre>\r\nrequire("cURL")\r\n\r\nc = cURL.easy_init()\r\n\r\nc:setopt_url("http://localhost")\r\npostdata = {\r\n -- post file from filesystem\r\n name = {file="post.lua",\r\n\t type="text/plain"},\r\n -- post file from data variable\r\n name2 = {file="dummy.html",\r\n\t data="<html><bold>bold</bold></html>",\r\n\t type="text/html"}}\r\nc:post(postdata)\r\nc:perform()\r\n\r\nprint("Done")\r\n</pre>\r\n</div>\r\n</div>\r\n<div>\r\n<h1><a href=\"#id7\" id=\"multi-interface\" name=\"multi-interface\">Multi interface</a></h1>\r\n<dl>\r\n<dt><strong>cURL.multi_init()</strong></dt>\r\n<dd>returns a new multi handle</dd>\r\n<dt><strong>multi:add_handle(easy)</strong></dt>\r\n<dd>add an easy handle to a multi session</dd>\r\n<dt><strong>multi:perform()</strong></dt>\r\n<dd><p>returns an iterator function that, each time it is called, returns the next data, type and corresponding easy handle:</p>\r\n<blockquote>\r\n<dl>\r\n<dt><strong>data</strong>:</dt>\r\n<dd>data returned by the cURL library</dd>\r\n<dt><strong>type</strong></dt>\r\n<dd>type of data returned ("header" or "data")</dd>\r\n<dt><strong>easy</strong></dt>\r\n<dd>corresponding easy handle of the data returned</dd>\r\n</dl>\r\n</blockquote>\r\n</dd>\r\n</dl>\r\n<div>\r\n<h2><a href=\"#id8\" id=\"example-1-on-the-fly-xml-parsing\" name=\"example-1-on-the-fly-xml-parsing\">Example 1: "On-The-Fly" XML parsing</a></h2>\r\n<pre>\r\n-- use LuaExpat and Lua-CuRL together for On-The-Fly XML parsing\r\nrequire("lxp")\r\nrequire("cURL")\r\n\r\ntags = {}\r\nitems = {}\r\n\r\ncallback = {}\r\n\r\nfunction callback.StartElement(parser, tagname)\r\n tags[#tags + 1] = tagname\r\n if (tagname == "item") then\r\n items[#items + 1] = {}\r\n end\r\nend\r\n\r\nfunction callback.CharacterData(parser, str)\r\n if (tags[#tags -1] == "item") then\r\n --we are parsing a item, get rid of trailing whitespace\r\n items[#items][tags[#tags]] = string.gsub(str, "%s*$", "")\r\n end\r\nend\r\nfunction callback.EndElement(parser, tagname)\r\n --assuming well formed xml\r\n tags[#tags] = nil\r\nend\r\n\r\np = lxp.new(callback)\r\n\r\n-- create and setup easy handle\r\nc = cURL.easy_init()\r\nc:setopt_url("http://www.lua.org/news.rss")\r\n\r\nm = cURL.multi_init()\r\nm:add_handle(c)\r\n\r\nfor data,type in m:perform() do\r\n -- ign "header"\r\n if (type == "data") then\r\n assert(p:parse(data))\r\n end\r\nend\r\n\r\n--finish document\r\nassert(p:parse())\r\np:close()\r\n\r\nfor i, item in ipairs(items) do\r\n for k, v in pairs(item) do\r\n print(k,v)\r\n end\r\n print()\r\nend\r\n</pre>\r\n</div>\r\n</div>\r\n<div>\r\n<h1><a href=\"#id9\" id=\"share-interface\" name=\"share-interface\">Share interface</a></h1>\r\n<dl id=\"share\">\r\n<dt><strong>cURL.share_init()</strong></dt>\r\n<dd>returns a new share handle</dd>\r\n<dt><strong>share:setopt_share(string)</strong></dt>\r\n<dd>specifies the type of data that should be shared ("DNS" or "COOKIE")</dd>\r\n</dl>\r\n<p>Since Lua is single-threaded, there is no mapping for the lock options.</p>\r\n<div>\r\n<h2><a href=\"#id10\" id=\"example-1-share-cookie-date-across-easy-handles\" name=\"example-1-share-cookie-date-across-easy-handles\">Example 1: Share Cookie date across easy handles</a></h2>\r\n<pre>\r\n-- Cookie data will be shared across the easy handles to do an authorized download\r\nrequire("cURL")\r\n\r\n-- create share handle (share COOKIE and DNS Cache)\r\ns = cURL.share_init()\r\ns:setopt_share("COOKIE")\r\ns:setopt_share("DNS")\r\n\r\n-- create first easy handle to do the login\r\nc = cURL.easy_init()\r\nc:setopt_share(s)\r\nc:setopt_url("http://targethost/login.php?username=foo&password=bar")\r\n\r\n-- create second easy handle to do the download\r\nc2 = cURL.easy_init()\r\nc2:setopt_share(s)\r\nc2:setopt_url("http://targethost/download.php?id=test")\r\n\r\n--login\r\nc:perform()\r\n\r\n--download\r\nc2:perform()\r\n</pre>\r\n</div>\r\n<div>\r\n<h1><a href=\"#id11\" id=\"appendix\" name=\"appendix\">Appendix</a></h1>\r\n<div>\r\n<h2><a href=\"#id12\" id=\"using-ssl\" name=\"using-ssl\">Using SSL</a></h2>\r\n<p>The cert bundle distributed with cURL may be out of date and cannot validate many certificates. You can supply a different\r\nPEM cert bundle by using <strong>easy:setopt_cainfo(string)</strong>.\r\nAlso, it is a shell script, writen by original author (Jürgen), that can be used for converting the cacert keystore distributed with the Java Runtime Environment to PEM. This script currently distributed in «examples» folder in repository</p>\r\n</div>\r\n</div>\r\n</div>","tagline":"Lua-cURL is aiming for a full-fledged libcurl binding (easy/multi/share interface) to the functionality of Lua","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}