/usr/share/doc/lua-curl-dev/curl.html is in lua-curl-dev 0.3.0-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | curl.lua<hr><h3>
cURL bindings.</h3>
<i>Description</i>: read the cURL curl_easy_setopt manpage.
As a convention all CURL_XXXXX and CURLXXXXX names are mapped to curl.XXXXX
constants. options taking a long now take a number, options taking a string
here take a string (no need to ensure the string will be available until
you call perform, the bindings do this for you). Functions to write like the
curl.OPT_WRITEFUNCTION and curl.OPT_HEADERFUNCTION take a string argument and
a number (the string len) must return a couple, byte,server and error message . if the number of byte returned is different from the string len it is
considered an error. this is an example of a callback factory: <br>
<pre style="color:blue;">
function build_w_cb(t)
return function(s,len)
<i>stores the received data in the table t</i>
table.insert(t,s)
<i>return number_of_byte_served, error_message</i>
<i>number_of_byte_served ~= len is an error</i>
return len,nil
end
end
</pre>
This cb factory stores all the chunks received in table t. you can have the
whole file back using table.concat(t). The callback for
curl.OPT_READFUNCTION takes a number, the number of the maximum amount of
data that can return. Here a simple example of an infinite stream of '#':<br>
<pre style="color:blue;">
function build_r_cb()
return function(n)
local s = string.rep("#",n)
<i>return size_of_data,data</i>
<i>size_of_data = 0 means end of data</i>
<i>size_of_data must be <= n</i>
return string.len(s),s
end
end
</pre>
curl_slist are mapped to lua tables {"item1","item2",...}. For example
curl.OPT_HTTPHEADER may be called in this way:<br>
<pre style="color:blue;">
c:setopt(curl.OPT_HTTPHEADER,{"Referer: my_home!","Dummy-field: hello"})
</pre>
Last important case is the curl.OPT_HTTPPOST for which a special syntax is
supported:
<pre style="color:blue;">
c:setopt(curl.OPT_HTTPPOST,{
{curl.FORM_COPYNAME,"name1",
curl.FORM_COPYCONTENTS,"data1",
curl.FORM_CONTENTTYPE,"Content-type: text/plain",
curl.FORM_END }
,
{curl.FORM_COPYNAME,"name2",
curl.FORM_COPYCONTENTS,"data2",
curl.FORM_CONTENTTYPE,"Content-type: text/plain",
curl.FORM_END}
})
</pre>
And now a simple example of an HTTP GET with a proxy:<br>
<pre style="color:blue;">
gl_b = {}
gl_h = {}
c = curl.easy_init()
c:setopt(curl.OPT_URL,'http://tassi.web.cs.unibo.it/cgi-bin/stats.cgi')
c:setopt(curl.OPT_WRITEFUNCTION,build_w_cb(gl_b))
c:setopt(curl.OPT_HEADERFUNCTION,build_w_cb(gl_h))
c:setopt(curl.OPT_PROXY,"localhost:3000")
c:setopt(curl.OPT_PROXYUSERPWD,"ciccio:ciccio")
print("\n\t$$ performing... returns code,error $$\n")
print(c:perform())
print("\n\t$$ here you see the header, line per line $$\n")
table.foreach(gl_h,function(i,s) print(i.."= "..string.gsub(s,"\n","")) end)
print("\n\t$$ and here you see the data, after concatenation of "..
table.getn(gl_b).." chunks $$\n")
print(table.concat(gl_b))
</pre>
<br>
<p style="margin:0 0 0 0;border-style:none">
</p><p style="margin:0 0 0 20;border-style:none">
</p>
<h3>
Functions
</h3><p style="margin:0 0 0 0;border-style:none">
<a href="#curl.easy_init"><code><b>curl.easy_init</code></b>
</a><code>()</code>
</p><p style="margin:0 0 0 20;border-style:none">
Create a curl handler.</p>
<p style="margin:0 0 0 0;border-style:none">
<a href="#curl.escape"><code><b>curl.escape</code></b>
</a><code>(s)</code>
</p><p style="margin:0 0 0 20;border-style:none">
URLencodes the string.</p>
<p style="margin:0 0 0 0;border-style:none">
<a href="#curl.unescape"><code><b>curl.unescape</code></b>
</a><code>(s)</code>
</p><p style="margin:0 0 0 20;border-style:none">
URLdecodes the string.</p>
<p style="margin:0 0 0 0;border-style:none">
<a href="#curl.version"><code><b>curl.version</code></b>
</a><code>()</code>
</p><p style="margin:0 0 0 20;border-style:none">
version.</p>
<p style="margin:0 0 0 0;border-style:none">
<a href="#curl.version_info"><code><b>curl.version_info</code></b>
</a><code>()</code>
</p><p style="margin:0 0 0 20;border-style:none">
version informations.</p>
<p style="margin:0 0 0 0;border-style:none">
<a href="#perform"><code><b>perform</code></b>
</a><code>()</code>
</p><p style="margin:0 0 0 20;border-style:none">
Starts curl.</p>
<p style="margin:0 0 0 0;border-style:none">
<a href="#setopt"><code><b>setopt</code></b>
</a><code>(opt,data)</code>
</p><p style="margin:0 0 0 20;border-style:none">
The setopt function.</p>
<ul>
<br><br>
</ul>
<p>
<h3>
Functions
</h3><a name="curl.easy_init"><code><b>curl.easy_init</code></b>
</a><code>()</code>
<ul>
<b>Create a curl handler.</b>
<br> <br>
<i>Return Value:</i> <b>userdata</b> The CURL* handler object.<br>
</ul>
<p>
<a name="curl.escape"><code><b>curl.escape</code></b>
</a><code>(s)</code>
<ul>
<b>URLencodes the string.</b>
<br> <br>
<i>Return Value:</i> <b>string</b> The escaped string.<br>
</ul>
<p>
<a name="curl.unescape"><code><b>curl.unescape</code></b>
</a><code>(s)</code>
<ul>
<b>URLdecodes the string.</b>
<br> <br>
<i>Return Value:</i> <b>string</b> The unescaped string.<br>
</ul>
<p>
<a name="curl.version"><code><b>curl.version</code></b>
</a><code>()</code>
<ul>
<b>version.</b>
<br> <br>
<i>Return Value:</i> <b>string</b> The version string.<br>
</ul>
<p>
<a name="curl.version_info"><code><b>curl.version_info</code></b>
</a><code>()</code>
<ul>
<b>version informations.</b>
<br> <br>
<i>Return Value:</i> <b>table</b> The version struct.<br>
</ul>
<p>
<a name="perform"><code><b>perform</code></b>
</a><code>()</code>
<ul>
<b>Starts curl.</b>
<br> <br>
<i>Return Value:</i> number,errorstring number not zero means an error.<br>
</ul>
<p>
<a name="setopt"><code><b>setopt</code></b>
</a><code>(opt,data)</code>
<ul>
<b>The setopt function.</b>
<br> <dt><i>Parameters</i><table>
<tr><td valign="top"><code>opt</code></td><td><b>number</b> one of curl.OPT_*</td></tr>
</table>
<br>
</ul>
<p>
<hr><small>This file was automatically generated by LuaDoc in 18 of August of 2006.</small>
|