-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathlcurl.ldoc
More file actions
662 lines (587 loc) · 17 KB
/
lcurl.ldoc
File metadata and controls
662 lines (587 loc) · 17 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
---
-- @module lcurl
do
--- Create HTTP multipart/formdata object.
--
-- @treturn[1] httpform new curl HTTP Post object context
function form() end
--- Create Easy object
--
-- @tparam[opt] table options
-- @treturn[1] easy new curl easy object
--
-- @usage
-- c = curl.easy{
-- url = 'http://example.com',
-- [curl.OPT_VERBOSE] = true,
-- }
--
function easy() end
--- Create Multi object
--
-- @tparam[opt] table options
-- @treturn[1] multi new curl multi object
--
-- @usage
-- m = curl.multi{
-- socketfunction = handle_socket;
-- timerfunction = start_timeout;
-- }
--
function multi() end
--- Create Share object
--
-- @tparam[opt] table options
-- @treturn[1] share new curl share object
function share() end
--- Returns libcurl version as human readable string
--
function version() end
--- Returns libcurl version as table
--
-- @tparam[opt] string param specific version info
-- @treturn[1] table full version into if `param` was not specify
-- @return[2] specific info parameter
--
-- @usage
-- proto = curl.version_info('protocols')
-- if proto.HTTP then ... -- libcurl support http protocol
function version_info() end
--- File description table.
--
-- Representation for `struct curl_fileinfo`
--
-- @table curl_fileinfo
--
-- @tfield string filename
-- @tfield integer filetype
-- @tfield integer time
-- @tfield integer perm
-- @tfield integer uid
-- @tfield integer gid
-- @tfield integer size
-- @tfield integer hardlinks
-- @tfield integer flags
-- @tfield table strings can have this string fields: `time`, `perm` , `user` , `group`, `target`
end
--- HTTP multipart/formdata object
-- @type httpform
--
do
--- Add new part to form.
--
-- @tparam string name provide the name of this part
-- @tparam string content actual data to send
-- @tparam[opt] string type provides the content-type for this part
-- @tparam[opt] table headers specifies extra headers for the form POST section
-- @return[1] self
function add_content() end
--- Add new part to form.
--
-- @tparam string name provide the name of this part
-- @tparam string filename provides the filename field in the content header
-- @tparam string content actual data to send
-- @tparam[opt] string type provides the content-type for this part
-- @tparam[opt] table headers specifies extra headers for the form POST section
-- @return[1] self
function add_buffer() end
--- Add new part to form.
--
-- @tparam string name provide the name of this part
-- @tparam string path path to file that contain actual data to send
-- @tparam[opt] string type provides the content-type for this part
-- @tparam[opt] string filename provides the filename field in the content header.
-- By default it is basename of path.
-- @tparam[opt] table headers specifies extra headers for the form POST section
-- @return[1] self
function add_file() end
--- Add new part to form.
--
-- @tparam string name provide the name of this part
-- @tparam[opt] string filename provides the filename field in the content header.
-- @tparam[opt] string type provides the content-type for this part
-- @tparam[opt] table headers specifies extra headers for the form POST section
-- @tparam number size stream size in bytes
-- @tparam function/object reader
-- @param[opt] context reader context
-- @return[1] self
--
-- @see easy:setopt_readfunction
function add_stream() end
--- Serialize multipart/formdata HTTP POST chain.
--
-- @return[1] string serialized data
--
-- @usage print(post:get())
--
function get() end
--- Serialize multipart/formdata HTTP POST chain.
--
-- Writer function can return true or number of written bytes.
-- Also if function does not return anything is considered as success.
--
-- @tparam function writer
-- @param[opt] context writer context
-- @return[1] self
--
-- @usage
-- t = {}
-- post:get(table.insert, t)
-- print(table.concat(t))
--
function get() end
--- Serialize multipart/formdata HTTP POST chain.
--
-- This call same as httpform:get(writer.write, writer)
--
-- @tparam object writer
-- @return[1] self
--
-- @usage
-- f = io.open(...)
-- post:get(f)
--
function get() end
--- Free multipart/formdata.
--
function free() end
end
--- Curl error object
-- @type error
--
-- !!!NOTE!!!: Always use cURL.safe in order to be able to use the error class functions.
-- perform() returns true/false and err contains the error message or nil if no error.
-- @usage
-- ok, err = context:perform()
--
do
--- Get the error category.
--
-- @treturn string string of error category (curl.ERROR_XXX constants)
--
-- @usage
-- if err:category() == curl.ERROR_EASY then
-- -- proceed easy error
-- end
function category ()end
--- Get the number value of error.
--
-- @treturn number number of error (curl.E_XXX constants)
function no ()end
--- Get the error name.
--
-- @treturn string error name (e.g. "UNSUPPORTED_PROTOCOL", "BAD_OPTION")
function name ()end
--- Get the error description.
--
-- @treturn string error description (e.g. "Login denied")
function msg ()end
--- Get the full error description.
--
-- @treturn string string that contain name, message and number of error
function __tostring ()end
end
--- Easy curl object
-- @type easy
--
do
--- Perform a file transfer
--
-- @return[1] self
function perfom() end
--- URL encodes the given string
--
-- @tparam string url
-- @return[1] encoded url
function escape() end
--- URL decodes the given string
--
-- @tparam string url
-- @return[1] decoded url
function unescape() end
--- Re-initializes all options previously set.
--
-- @treturn easy self
function reset() end
--- Pause and unpause a connection.
--
-- @tparam number mask set of bits that sets the new state of the connection (one of PAUSE_XXX constant)
-- @treturn easy self
function pause() end
--- End easy session
--
function close() end
--- Set options.
--
-- @tparam number|table opt one of `curl.OPT_XXX` constant or options table
-- @param ... value
-- @treturn easy self
--
-- @usage
-- c:setopt(curl.OPT_URL, "http://example.com")
-- c:setopt(curl.OPT_READFUNCTION,
-- function(t, n) return table.remove(t) end,
-- {"1111", "2222"}
-- )
--c:setopt{
-- url = 'http://example.com',
-- [curl.OPT_VERBOSE] = true,
-- }
function setopt() end
--- Reset option to default value.
--
-- @tparam number opt one of `curl.OPT_XXX` constant or options table
-- @treturn easy self
--
-- @usage
-- c:unsetopt(curl.OPT_URL)
-- c:unsetopt(curl.OPT_READFUNCTION)
function unsetopt() end
--- Get information.
--
-- @tparam number info one of `curl.INFO_XXX` constant
-- @return value
--
-- @usage
-- print(c:getinfo(curl.INFO_EFFECTIVE_URL))
-- print(c:getinfo(curl.INFO_TOTAL_TIME))
-- print(c:getinfo(curl.INFO_RESPONSE_CODE))
function getinfo() end
--- Set writer function.
--
-- A callback accepting one or two parameters.
-- The first is the writer context if any, and the second is a string with the data to be written.
-- Function must return `true` (any non number true value) or full data length or nothing to continue operation.
-- Otherwise the transfer will be aborted with an error.
--
-- @tparam function writer
-- @param[opt] context writer context
-- @return[1] self
--
function setopt_writefunction() end
--- Set writer function.
--
-- This call same as easy:setopt_writefunction(writer.write, writer)
--
-- @tparam object writer
-- @return[1] self
--
function setopt_writefunction() end
--- Set header function.
--
-- A callback accepting one or two parameters.
-- The first is the writer context if any, and the second is a string with the data to be written.
-- Function must return `true` (any non number true value) or full data length or nothing to continue operation.
-- Otherwise the transfer will be aborted with an error.
--
-- @tparam function writer
-- @param[opt] context writer context
-- @return[1] self
--
function setopt_headerfunction() end
--- Set header function.
--
-- This call same as easy:setopt_headerfunction(writer.header, writer)
--
-- @tparam object writer
-- @return[1] self
--
function setopt_headerfunction() end
--- Set reader function.
--
-- A callback accepting one or two parameters.
-- The first is the reader context if any, and the second is the maximum amount of data to be read.
-- You can ignore second argument and pass as mach data as you need. lcurl can split data.
-- Function must return data to continue operation. To stop operation it must return empty string or nil or nothing.
-- Otherwise the transfer will be aborted with an error.
--
--
-- @tparam function reader
-- @param[opt] context reader context
-- @return[1] self
--
-- @usage
-- local counter = 10
-- c:setopt_readfunction(function()
-- if counter > 0 then
-- counter = counter - 1
-- return 'a'
-- end
-- end)
function setopt_readfunction() end
--- Set reader function.
--
-- This call same as easy:setopt_readfunction(reader.read, reader)
--
-- @tparam object reader
-- @return[1] self
--
function setopt_readfunction() end
--- Set progress function.
--
-- A callback accepting four or five parameters.
-- The first is the reader context if any, the second is the total number
-- of bytes expected to be downloaded in this transfer,
-- the third is the number of bytes downloaded so far,
-- the fourth is the total number of bytes expected to be uploaded
-- in this transfer, and the fifth is the number of bytes uploaded so far.
-- Function must return `true` or `1` or nothing to continue operation.
-- Otherwise the transfer will be aborted with an error `ABORTED_BY_CALLBACK`.<br/>
--
-- !!! NOTE !!! This is differents form libcurl API. In libcurl returning a non-zero
-- value from this callback will cause libcurl to abort the transfer and return.
-- This done to be consisted with writefunction that should return `true` to continue.
--
-- @tparam function progress
-- @param[opt] context progress context
-- @return[1] self
--
function setopt_progressfunction() end
--- Set progress function.
--
-- This call same as easy:setopt_progressfunction(progress.progress, progress)
--
-- @tparam object progress
-- @return[1] self
--
function setopt_progressfunction() end
--- Set seek callback function.
--
-- A callback accepting two or three parameters.
-- The first is the seek context if any, the second is the `origin` value
-- same as in file.seek function from io library. Can be (`cur`, `set` and `end`).
-- The third parameter is offset or position in input stream.
-- If stream can not be seeking and need stop current transfer operation
-- function have to raise Lua error or returns `nil` and error message.
-- To indicate success function have to return any truthy value
-- In other case Function must return `true` or `1` or nothing to continue operation.
-- False value indicate that while the seek failed, libcurl is free to work
-- around the problem if possible.
--
-- !!! NOTE !!! This is differents form libcurl API by swapping parameters in callback.
-- It done to be compatiable with Lua io library.
--
-- @tparam function seek
-- @param[opt] context seek context
-- @return[1] self
--
function setopt_seekfunction() end
--- Set seek callback function.
--
-- This call same as easy:setopt_seekfunction(stream.seek, seek)
--
-- @tparam object stream
-- @return[1] self
--
function setopt_seekfunction() end
--- Set debug callback function.
--
-- A callback accepting two or three parameters.
-- The first is the debug context if any, the second is the `data_type` value
-- which represent what kinde of data is passed. This value can be one of
-- constant `INFO_TEXT`, `INFO_HEADER_IN`, `INFO_HEADER_OUT`, `INFO_DATA_IN`,
-- `INFO_DATA_OUT`, `INFO_SSL_DATA_IN`, `INFO_SSL_DATA_OUT`.
-- The third parameter is data itself.
-- Any errors and returning values from this callback are ignored.
--
-- @tparam function debug
-- @param[opt] context debug context
-- @return[1] self
--
function setopt_debugfunction() end
--- Set debug callback function.
--
-- This call same as easy:setopt_debugfunction(debug.debug, debug)
--
-- @tparam object debug
-- @return[1] self
--
function setopt_debugfunction() end
--- Set match callback function.
--
-- A callback accepting two or three parameters.
-- The first is the match context if any, the second is the pattern string,
-- the third is the string to match to pattern.
-- Function must return truthy value to indicate that string match to pattern.
-- If function raise error or return nil and error message then it indicate
-- that curl should interrupt current transfer operation.
-- False value indicate that strind does not match to pattern
--
-- @tparam function match
-- @param[opt] context match context
-- @return[1] self
--
function setopt_fnmatch_function() end
--- Set match callback function.
--
-- This call same as easy:setopt_fnmatch_function(match.match, match)
--
-- @tparam object match
-- @return[1] self
--
function setopt_fnmatch_function() end
--- Set chunk begin function.
--
-- A callback accepting two or three parameters.
-- The first is the chunk context if any, the second is the @{curl_fileinfo} table.
-- The third parameter contains number of chunks remaining per the transfer.
-- Function must return truthy value or nothing to indicate that transfer can begin.
-- If function raise error or return nil and error message then it indicate
-- that curl should interrupt current transfer operation.
-- False value indicate that curl should skip this chunk.
--
-- @tparam function chunk_bgn
-- @param[opt] context chunk context
-- @return[1] self
--
function setopt_chunk_bgn_function() end
--- Set chunk begin function.
--
-- This call same as easy:setopt_chunk_bgn_function(context.chunk_bgn, context)
--
-- @tparam object context
-- @return[1] self
--
function setopt_chunk_bgn_function() end
--- Set chunk end function.
--
-- A callback accepting zero or one parameter.
-- The only parameter is the chunk context if any.
-- Function must return truthy value or nothing to indicate that transfer can continue
-- otherwise it indicate that curl should interrupt current transfer operation.
--
-- @tparam function chunk_end
-- @param[opt] context chunk context
-- @return[1] self
--
function setopt_chunk_end_function() end
--- Set chunk begin function.
--
-- This call same as easy:setopt_chunk_end_function(context.chunk_end, context)
--
-- @tparam object context
-- @return[1] self
--
function setopt_chunk_end_function() end
--- Set HTTP multipart/formdata.
--
-- Caller does not have to save data.
--
-- @tparam httpform data
-- @return[1] self
function setopt_httppost() end
--- Set HTTP multipart/formdata.
--
-- @tparam string data
-- @tparam[opt=#data] number length
-- @return[1] self
function setopt_postfields() end
--- Set curl share object.
--
-- Caller does not have to save data.
--
-- @tparam share data
-- @return[1] self
function setopt_share() end
end
--- Muli curl object
-- @type multi
--
do
--- Add Easy object.
--
-- Caller must ensure that easy object is alive until end of operation.
--
-- @treturn multi self
-- @tparam easy handle
function add_handle() end
--- Remove Easy object.
--
-- @tparam easy handle
-- @treturn multi self
function remove_handle() end
--- reads/writes available data from each easy handle.
--
-- @treturn number handles number of active easy handles
function perfom() end
--- Read multi stack informationals.
--
-- Note. If curl_multi_remove_handle fail then there no error occure but handle jast stay in multi handle.
--
-- @tparam[opt] remove remove easy handle if it done.
-- @treturn[1] number 0 there no informationals
-- @treturn[2] easy handle
-- @treturn[2] boolean true
-- @treturn[3] easy handle
-- @treturn[3] nil
-- @treturn[3] error error code
function info_read() end
--- Set options.
--
-- @tparam number|table opt one of `curl.OPT_MULTI_XXX` constant
-- @param ... value
-- @treturn multi self
--
-- @usage
-- c:setopt(curl.OPT_MULTI_MAXCONNECTS, 10)
-- c:setopt{maxconnects = 10}
function setopt() end
--- Perform socket action.
--
-- @tparam[opt=curl.SOCKET_TIMEOUT] number socket
-- @tparam[opt=0] number mask
-- @treturn multi self
--
-- @usage
-- c:socket_action()
-- c:socket_action(sock_fd, curl.CSELECT_IN)
-- c:socket_action(sock_fd, curl.CSELECT_OUT)
function socket_action() end
--- Set timer callback.
--
-- @tparam function timer timer callback
-- @param[opt] context timer context
-- @treturn multi self
--
function setopt_timerfunction() end
--- Set timer callback.
--
-- This call same as easy:setopt_writefunction(timer.timer, timer)
--
-- @tparam userdata|table timer timer object
-- @treturn multi self
--
function setopt_timerfunction() end
--- Polls on all easy objects in a multi object.
--
-- @tparam[opt] number timeout milliseconds timeout. By default it is `multi:timeout()`.
-- @treturn number number of affected objects
--
function wait() end
--- How long to wait for action before proceeding.
--
-- @treturn number timeout milliseconds timeout
--
function timeout() end
--- End multi session.
--
function close() end
end
--- Share curl object
-- @type share
--
do
--- Set options.
--
-- @tparam number|table opt one of `curl.OPT_SHARE_XXX` constant
-- @param ... value
-- @treturn share self
--
-- @usage
-- c:setopt(curl.OPT_SHARE_SHARE, curl.LOCK_DATA_COOKIE)
-- c:setopt{share = curl.LOCK_DATA_COOKIE}
function setopt() end
--- End share session.
--
function close() end
end