7d28842626159d512781c942a3f7f16681c64127
[nit.git] / lib / curl / curl_c.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2013 Matthieu Lucas <lucasmatthieu@gmail.com>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Binding of C libCurl which allow us to interact with network.
18 module curl_c is pkgconfig("libcurl")
19
20 in "C header" `{
21 #include <curl/curl.h>
22
23 typedef enum {
24 CURLcallbackTypeHeader,
25 CURLcallbackTypeBody,
26 CURLcallbackTypeStream,
27 CURLcallbackTypeRead,
28 } CURLcallbackType;
29
30 typedef struct {
31 CCurlCallbacks delegate;
32 CURLcallbackType type;
33 } CURLCallbackDatas;
34
35 typedef struct {
36 char *data;
37 int len;
38 int pos;
39 } CURLCallbackReadDatas;
40 `}
41
42 in "C body" `{
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include <string.h>
46
47 // Callbacks method for Header, Body, Stream.
48 size_t nit_curl_callback_func(void *buffer, size_t size, size_t count, CURLCallbackDatas *datas){
49 if(datas->type == CURLcallbackTypeHeader){
50 char *line_c = (char*)buffer;
51 String line_o = NativeString_to_s_with_copy(line_c);
52 CCurlCallbacks_header_callback(datas->delegate, line_o);
53 }
54 else if(datas->type == CURLcallbackTypeBody){
55 char *line_c = (char*)buffer;
56 String line_o = NativeString_to_s_with_copy(line_c);
57 CCurlCallbacks_body_callback(datas->delegate, line_o);
58 }
59 else if(datas->type == CURLcallbackTypeStream){
60 char *line_c = (char*)buffer;
61 String line_o = NativeString_to_s(line_c);
62 CCurlCallbacks_stream_callback(datas->delegate, line_o, size, count);
63 }
64 return count;
65 }
66
67 // Callback method to read datas from buffer.
68 size_t nit_curl_callback_read_func(void *buffer, size_t size, size_t count, CURLCallbackReadDatas *datas){
69 int len = datas->len - datas->pos;
70 if(len > size * count) len = size * count;
71 memcpy(buffer, datas->data + datas->pos, len);
72 datas->pos += len;
73 return len;
74 }
75 `}
76
77 # CURL Extern Type, reproduce CURL low level behaviors
78 extern class CCurl `{ CURL * `}
79 # Constructor, CURL low level initializer
80 new easy_init `{ return curl_easy_init(); `}
81
82 # Check for correct initialization
83 fun is_init: Bool `{ return (self != NULL); `}
84
85 # Easy Clean / Release CURL instance
86 fun easy_clean `{ curl_easy_cleanup( self ); `}
87
88 # Perform the transfer described by setted options
89 # Set options to tell CURL how to behave. Obj parameter type can be Int, Bool, String, OFile, CURLSList.
90 fun easy_perform: CURLCode `{ return curl_easy_perform( self ); `}
91 fun easy_setopt(opt: CURLOption, obj: Object): CURLCode
92 do
93 if obj isa Int then return i_setopt_int(opt, obj)
94 if obj isa Bool and obj == true then return i_setopt_int(opt, 1)
95 if obj isa Bool and obj == false then return i_setopt_int(opt, 0)
96 if obj isa String then return i_setopt_string(opt, obj)
97 if obj isa OFile then return i_setopt_file(opt, obj)
98 if obj isa CURLSList then return i_setopt_slist(opt, obj)
99 return once new CURLCode.unknown_option
100 end
101 # Internal method to set options to CURL using OFile parameter.
102 private fun i_setopt_file(opt: CURLOption, fl: OFile):CURLCode `{ return curl_easy_setopt( self, opt, fl); `}
103
104 # Internal method to set options to CURL using Int parameter.
105 private fun i_setopt_int(opt: CURLOption, num: Int): CURLCode `{ return curl_easy_setopt( self, opt, num); `}
106
107 # Internal method to set options to CURL using CURLSList parameter.
108 private fun i_setopt_slist(opt: CURLOption, list: CURLSList): CURLCode `{ return curl_easy_setopt( self, opt, list); `}
109
110 # Internal method to set options to CURL using String parameter.
111 private fun i_setopt_string(opt: CURLOption, str: String): CURLCode import String.to_cstring `{
112 char *rStr = String_to_cstring(str);
113 return curl_easy_setopt( self, opt, rStr);
114 `}
115
116 # Request Chars internal information from the CURL session
117 fun easy_getinfo_chars(opt: CURLInfoChars): nullable CURLInfoResponseString
118 do
119 var answ = new CURLInfoResponseString
120 if not i_getinfo_chars(opt, answ).is_ok then return null
121 return answ
122 end
123
124 # Internal method used to get String object information initially knowns as C Chars type
125 private fun i_getinfo_chars(opt: CURLInfoChars, res: CURLInfoResponseString): CURLCode import CURLInfoResponseString.response=, NativeString.to_s_with_copy `{
126 char *r = NULL;
127 CURLcode c = curl_easy_getinfo( self, opt, &r);
128 if((c == CURLE_OK) && r != NULL){
129 String ro = NativeString_to_s_with_copy(r);
130 CURLInfoResponseString_response__assign( res, ro);
131 }
132 return c;
133 `}
134
135 # Request Long internal information from the CURL session
136 fun easy_getinfo_long(opt: CURLInfoLong): nullable CURLInfoResponseLong
137 do
138 var answ = new CURLInfoResponseLong
139 if not i_getinfo_long(opt, answ).is_ok then return null
140 return answ
141 end
142
143 # Internal method used to get Int object information initially knowns as C Long type
144 private fun i_getinfo_long(opt: CURLInfoLong, res: CURLInfoResponseLong): CURLCode import CURLInfoResponseLong.response= `{
145 long *r = NULL;
146 r = malloc(sizeof(long));
147 CURLcode c = curl_easy_getinfo( self, opt, r);
148 if((c == CURLE_OK) && r != NULL) CURLInfoResponseLong_response__assign( res, *r);
149 free(r);
150 return c;
151 `}
152
153 # Request Double internal information from the CURL session
154 fun easy_getinfo_double(opt: CURLInfoDouble): nullable CURLInfoResponseDouble
155 do
156 var answ = new CURLInfoResponseDouble
157 if not i_getinfo_double(opt, answ).is_ok then return null
158 return answ
159 end
160
161 # Internal method used to get Int object information initially knowns as C Double type
162 private fun i_getinfo_double(opt: CURLInfoDouble, res: CURLInfoResponseDouble): CURLCode import CURLInfoResponseDouble.response= `{
163 double *r = NULL;
164 r = malloc(sizeof(double));
165 CURLcode c = curl_easy_getinfo( self, opt, r);
166 if((c == CURLE_OK) && r != NULL) CURLInfoResponseDouble_response__assign( res, *r);
167 free(r);
168 return c;
169 `}
170
171 # Request SList internal information from the CURL session
172 fun easy_getinfo_slist(opt: CURLInfoSList): nullable CURLInfoResponseArray
173 do
174 var answ = new CURLInfoResponseArray
175 if not i_getinfo_slist(opt, answ).is_ok then return null
176 answ.response = answ.prim_response.to_a
177 answ.prim_response.destroy
178 return answ
179 end
180
181 # Internal method used to get Array[String] object information initially knowns as C SList type
182 private fun i_getinfo_slist(opt: CURLInfoSList, res: CURLInfoResponseArray): CURLCode import CURLInfoResponseArray.prim_response= `{
183 struct curl_slist* csl = NULL;
184 CURLcode ce = curl_easy_getinfo( self, opt, &csl);
185 CURLInfoResponseArray_prim_response__assign(res, csl);
186 return ce;
187 `}
188
189 # Register delegate to get callbacks about the CURL transfer performed
190 fun register_callback(delegate: CCurlCallbacks, cbtype: CURLCallbackType): CURLCode
191 do
192 if once [new CURLCallbackType.header, new CURLCallbackType.body, new CURLCallbackType.stream, new CURLCallbackType.read].has(cbtype) then
193 return i_register_callback(delegate, cbtype)
194 end
195 return once new CURLCode.unknown_option
196 end
197
198 # Register delegate to read datas from given buffer
199 fun register_read_datas_callback(delegate: CCurlCallbacks, datas: String): CURLCode
200 do
201 if datas.length > 0 then return i_register_read_datas_callback(delegate, datas, datas.length)
202 return once new CURLCode.unknown_option
203 end
204
205 # Internal method used to configure read callback
206 private fun i_register_read_datas_callback(delegate: CCurlCallbacks, datas: String, size: Int): CURLCode import String.to_cstring `{
207 CURLCallbackReadDatas *d = NULL;
208 d = malloc(sizeof(CURLCallbackReadDatas));
209 d->data = (char*)String_to_cstring(datas);
210 d->len = size;
211 d->pos = 0;
212 return curl_easy_setopt( self, CURLOPT_READDATA, d);
213 `}
214
215 # Internal method used to configure callbacks in terms of given type
216 private fun i_register_callback(delegate: CCurlCallbacks, cbtype: CURLCallbackType):CURLCode is extern import CCurlCallbacks.native_header_callback, CCurlCallbacks.native_body_callback, CCurlCallbacks.native_stream_callback `{
217 CURLCallbackDatas *d = malloc(sizeof(CURLCallbackDatas));
218 CCurlCallbacks_incr_ref(delegate);
219 d->type = cbtype;
220 d->delegate = delegate;
221 CURLcode e;
222 switch(cbtype){
223 case CURLcallbackTypeHeader:
224 e = curl_easy_setopt( self, CURLOPT_HEADERFUNCTION, (curl_write_callback)&nit_curl_callback_func);
225 if(e != CURLE_OK) return e;
226 e = curl_easy_setopt( self, CURLOPT_WRITEHEADER, d);
227 break;
228 case CURLcallbackTypeBody:
229 case CURLcallbackTypeStream:
230 e = curl_easy_setopt( self, CURLOPT_WRITEFUNCTION, (curl_write_callback)&nit_curl_callback_func);
231 if(e != CURLE_OK) return e;
232 e = curl_easy_setopt( self, CURLOPT_WRITEDATA, d);
233 break;
234 case CURLcallbackTypeRead:
235 e = curl_easy_setopt( self, CURLOPT_READFUNCTION, (curl_write_callback)&nit_curl_callback_read_func);
236 default:
237 break;
238 }
239 return e;
240 `}
241
242 # Convert given string to URL encoded string
243 fun escape(url: String): String import String.to_cstring, NativeString.to_s_with_copy `{
244 char *orig_url, *encoded_url = NULL;
245 orig_url = String_to_cstring(url);
246 encoded_url = curl_easy_escape( self, orig_url, strlen(orig_url));
247 String b_url = NativeString_to_s_with_copy(encoded_url);
248 curl_free(encoded_url);
249 return b_url;
250 `}
251 end
252
253 # FILE Extern type, reproduce basic FILE I/O
254 extern class OFile `{ FILE* `}
255 # Open / Create a file from given name
256 new open(str: NativeString) `{ return fopen(str, "wb"); `}
257 # Check for File validity
258 fun is_valid:Bool `{ return self != NULL; `}
259 # Internal method to write to the current file
260 private fun n_write(buffer: NativeString, size: Int, count: Int):Int `{ return fwrite(buffer, size, count, self); `}
261 # Write datas to the current file
262 fun write(buffer: String, size: Int, count: Int):Int
263 do
264 if is_valid == true then return n_write(buffer.to_cstring, size, count)
265 return 0
266 end
267 # Internal method to close the current file
268 private fun n_close:Int `{ return fclose(self); `}
269 # Close the current file
270 fun close:Bool
271 do
272 if is_valid == true then return n_close == 0
273 return false
274 end
275 end
276
277 # Interface for internal information callbacks methods
278 interface CCurlCallbacks
279 fun header_callback(line: String) is abstract
280 fun body_callback(line: String) is abstract
281 fun stream_callback(buffer: String, size: Int, count: Int) is abstract
282 end
283
284 # Extern Type to reproduce Enum of available Callback type
285 extern class CURLCallbackType `{ CURLcallbackType `}
286 new header `{ return CURLcallbackTypeHeader; `}
287 new body `{ return CURLcallbackTypeBody; `}
288 new stream `{ return CURLcallbackTypeStream; `}
289 new read `{ return CURLcallbackTypeRead; `}
290
291 fun to_i: Int `{ return self; `}
292 end
293
294 # CURL Code binding and helpers
295 extern class CURLCode `{ CURLcode `}
296 new unknown_option `{ return CURLE_UNKNOWN_OPTION; `}
297 new unsupported_protocol `{ return CURLE_UNSUPPORTED_PROTOCOL; `}
298 new ok `{ return CURLE_OK; `}
299 new failed_init `{ return CURLE_FAILED_INIT; `}
300
301 fun code: Int `{ return self; `}
302 fun is_ok: Bool `{ return self == CURLE_OK; `}
303 fun is_valid_protocol: Bool `{ return self == CURLE_UNSUPPORTED_PROTOCOL; `}
304 fun is_valid_init: Bool `{ return self == CURLE_FAILED_INIT; `}
305 fun to_i: Int do return code end
306 redef fun to_s import NativeString.to_s_with_copy `{
307 char *c = (char*)curl_easy_strerror(self);
308 return NativeString_to_s_with_copy(c);
309 `}
310 end
311
312 # Extern Type of the Linked list type of CURL
313 extern class CURLSList `{ struct curl_slist * `}
314 # Empty constructor which allow us to avoid the use of Nit NULLABLE type
315 private new `{ return NULL; `}
316
317 # Constructor allow us to get list instancied by appending an element inside.
318 new with_str(s: String) import String.to_cstring `{
319 struct curl_slist *l = NULL;
320 l = curl_slist_append(l, String_to_cstring(s));
321 return l;
322 `}
323
324 # Check for initialization
325 fun is_init: Bool `{ return (self != NULL); `}
326
327 # Append an element in the linked list
328 fun append(key: String) import String.to_cstring `{
329 char *k = String_to_cstring(key);
330 curl_slist_append(self, (char*)k);
331 `}
332
333 # Internal method to check for reachability of current data
334 private fun i_data_reachable(c: CURLSList): Bool `{ return (c != NULL && c->data != NULL); `}
335
336 # Internal method to check for reachability of next element
337 private fun i_next_reachable(c: CURLSList): Bool `{ return (c != NULL && c->next != NULL); `}
338
339 # Internal method to get current data
340 private fun i_data(c: CURLSList): String import NativeString.to_s `{ return NativeString_to_s(c->data); `}
341
342 # Internal method to get next element
343 private fun i_next(c: CURLSList): CURLSList `{ return c->next; `}
344
345 # Convert current low level List to an Array[String] object
346 fun to_a: Array[String]
347 do
348 var r = new Array[String]
349 var cursor = self
350 loop
351 if i_data_reachable(cursor) != true then break
352 r.add(i_data(cursor))
353 cursor = i_next(cursor)
354 end
355 return r
356 end
357
358 # Release allocated memory
359 fun destroy `{ curl_slist_free_all(self); `}
360 end
361
362 redef class Collection[E]
363 # Convert Collection[String] to CURLSList
364 fun to_curlslist: CURLSList
365 do
366 assert collectionItemType: self isa Collection[String] else
367 print "Collection item must be strings."
368 end
369 var primList = new CURLSList.with_str(self.first)
370 var is_first = true
371 for s in self do
372 if not is_first then primList.append(s)
373 is_first = false
374 end
375 return primList
376 end
377 end
378
379 # Array Response type of CCurl.easy_getinfo method
380 class CURLInfoResponseArray
381 var response: Array[String] = new Array[String]
382 private var prim_response: CURLSList = new CURLSList
383 end
384
385 # Long Response type of CCurl.easy_getinfo method
386 class CURLInfoResponseLong
387 var response = 0
388 end
389
390 # Double Response type of CCurl.easy_getinfo method
391 class CURLInfoResponseDouble
392 var response = 0
393 end
394
395 # String Response type of CCurl::easy_getinfo method
396 class CURLInfoResponseString
397 var response = ""
398 end
399
400 # Reproduce Enum of available CURL SList information, used for CCurl.easy_getinfo
401 extern class CURLInfoSList `{ CURLINFO `}
402 new ssl_engines `{ return CURLINFO_SSL_ENGINES; `}
403 new cookielist `{ return CURLINFO_COOKIELIST; `}
404 end
405
406 # Reproduce Enum of available CURL Long information, used for CCurl.easy_getinfo
407 extern class CURLInfoLong `{ CURLINFO `}
408 new response_code `{ return CURLINFO_RESPONSE_CODE; `}
409 new header_size `{ return CURLINFO_HEADER_SIZE; `}
410 new http_connectcode `{ return CURLINFO_HTTP_CONNECTCODE; `}
411 new filetime `{ return CURLINFO_FILETIME; `}
412 new redirect_count `{ return CURLINFO_REDIRECT_COUNT; `}
413 new request_size `{ return CURLINFO_REQUEST_SIZE; `}
414 new ssl_verifyresult `{ return CURLINFO_SSL_VERIFYRESULT; `}
415 new httpauth_avail `{ return CURLINFO_HTTPAUTH_AVAIL; `}
416 new proxyauth_avail `{ return CURLINFO_PROXYAUTH_AVAIL; `}
417 new os_errno `{ return CURLINFO_OS_ERRNO; `}
418 new num_connects `{ return CURLINFO_NUM_CONNECTS; `}
419 new primary_port `{ return CURLINFO_PRIMARY_PORT; `}
420 new local_port `{ return CURLINFO_LOCAL_PORT; `}
421 new lastsocket `{ return CURLINFO_LASTSOCKET; `}
422 new condition_unmet `{ return CURLINFO_CONDITION_UNMET; `}
423 new rtsp_client_cseq `{ return CURLINFO_RTSP_CLIENT_CSEQ; `}
424 new rtsp_server_cseq `{ return CURLINFO_RTSP_SERVER_CSEQ; `}
425 new rtsp_cseq_self `{ return CURLINFO_RTSP_CSEQ_RECV; `}
426 end
427
428 # Reproduce Enum of available CURL Double information, used for CCurl.easy_getinfo
429 extern class CURLInfoDouble `{ CURLINFO `}
430 new total_time `{ return CURLINFO_TOTAL_TIME; `}
431 new namelookup_time `{ return CURLINFO_NAMELOOKUP_TIME; `}
432 new connect_time `{ return CURLINFO_CONNECT_TIME; `}
433 new appconnect_time `{ return CURLINFO_APPCONNECT_TIME; `}
434 new pretransfer_time `{ return CURLINFO_PRETRANSFER_TIME; `}
435 new starttransfer_time `{ return CURLINFO_STARTTRANSFER_TIME; `}
436 new redirect_time `{ return CURLINFO_REDIRECT_TIME; `}
437 new size_upload `{ return CURLINFO_SIZE_UPLOAD; `}
438 new size_download `{ return CURLINFO_SIZE_DOWNLOAD; `}
439 new speed_download `{ return CURLINFO_SPEED_DOWNLOAD; `}
440 new speed_upload `{ return CURLINFO_SPEED_UPLOAD; `}
441 new content_length_download `{ return CURLINFO_CONTENT_LENGTH_DOWNLOAD; `}
442 new content_length_upload `{ return CURLINFO_CONTENT_LENGTH_UPLOAD; `}
443 end
444
445 # Reproduce Enum of available CURL Chars information, used for CCurl.easy_getinfo
446 extern class CURLInfoChars `{ CURLINFO `}
447 new content_type `{ return CURLINFO_CONTENT_TYPE; `}
448 new effective_url `{ return CURLINFO_EFFECTIVE_URL; `}
449 new redirect_url `{ return CURLINFO_REDIRECT_URL; `}
450 new primary_ip `{ return CURLINFO_PRIMARY_IP; `}
451 new local_ip `{ return CURLINFO_LOCAL_IP; `}
452 new ftp_entry_path `{ return CURLINFO_FTP_ENTRY_PATH; `}
453 new rtsp_session_id `{ return CURLINFO_RTSP_SESSION_ID; `}
454 new private_data `{ return CURLINFO_PRIVATE; `}
455 end
456
457 # Reproduce Enum of HTTP Status Code
458 extern class CURLStatusCode `{ int `}
459 new proceed `{ return 100; `}
460 new switching_protocols `{ return 101; `}
461 new ok `{ return 200; `}
462 new created `{ return 201; `}
463 new accepted `{ return 202; `}
464 new non_authoritative_information `{ return 203; `}
465 new no_content `{ return 204; `}
466 new reset_content `{ return 205; `}
467 new partial_content `{ return 206; `}
468 new multiple_choices `{ return 300; `}
469 new moved_permanently `{ return 301; `}
470 new moved_temporarily `{ return 302; `}
471 new see_other `{ return 303; `}
472 new not_modified `{ return 304; `}
473 new use_proxy `{ return 305; `}
474 new bad_request `{ return 400; `}
475 new unauthorized `{ return 401; `}
476 new payment_required `{ return 402; `}
477 new forbidden `{ return 403; `}
478 new not_found `{ return 404; `}
479 new method_not_allowed `{ return 405; `}
480 new not_acceptable `{ return 406; `}
481 new proxy_authentication_required `{ return 407; `}
482 new request_timeout `{ return 408; `}
483 new conflict `{ return 409; `}
484 new gone `{ return 410; `}
485 new length_required `{ return 411; `}
486 new precondition_failed `{ return 412; `}
487 new request_entity_too_large `{ return 413; `}
488 new request_uri_too_large `{ return 414; `}
489 new unsupported_media_type `{ return 415; `}
490 new internal_server_error `{ return 500; `}
491 new not_implemented `{ return 501; `}
492 new bad_gateway `{ return 502; `}
493 new service_unavailable `{ return 503; `}
494 new gateway_timeout `{ return 504; `}
495 new http_version_not_supported `{ return 505; `}
496 fun to_i: Int `{ return self; `}
497 end
498
499 # Reproduce Enum of CURL Options usable, used for CCurl.easy_setopt
500 extern class CURLOption `{ CURLoption `}
501
502 # Behavior options
503
504 # Display verbose information.
505 new verbose `{ return CURLOPT_VERBOSE; `}
506
507 # Include the header in the body output.
508 new header `{ return CURLOPT_HEADER; `}
509
510 # Shut off the progress meter.
511 new no_progress `{ return CURLOPT_NOPROGRESS; `}
512
513 # Do not install signal handlers.
514 new no_signal `{ return CURLOPT_NOSIGNAL; `}
515
516 # Transfer multiple files according to a file name pattern.
517 new wild_card_match `{ return CURLOPT_WILDCARDMATCH; `}
518
519 # Callback Options
520
521 # Callback for writing data.
522 new write_function `{ return CURLOPT_WRITEFUNCTION; `}
523
524 # Data pointer to pass to the write callback.
525 new write_data `{ return CURLOPT_WRITEDATA; `}
526
527 # new `{ return CURLOPT_READFUNCTION; `}
528 # new `{ return CURLOPT_READDATA; `}
529 # new `{ return CURLOPT_IOCTLFUNCTION; `}
530 # new `{ return CURLOPT_IOCTLDATA; `}
531 # new `{ return CURLOPT_SEEKFUNCTION; `}
532 # new `{ return CURLOPT_SEEKDATA; `}
533 # new `{ return CURLOPT_SOCKOPTFUNCTION; `}
534 # new `{ return CURLOPT_SOCKOPTDATA; `}
535 # new `{ return CURLOPT_OPENSOCKETFUNCTION; `}
536 # new `{ return CURLOPT_OPENSOCKETDATA; `}
537 # new `{ return CURLOPT_CLOSESOCKETFUNCTION; `}
538 # new `{ return CURLOPT_CLOSESOCKETDATA; `}
539 # new `{ return CURLOPT_PROGRESSFUNCTION; `}
540 # new `{ return CURLOPT_PROGRESSDATA; `}
541 # new `{ return CURLOPT_HEADERFUNCTION; `}
542 # new `{ return CURLOPT_DEBUGFUNCTION; `}
543 # new `{ return CURLOPT_DEBUGDATA; `}
544 # new `{ return CURLOPT_SSL_CTX_FUNCTION; `}
545 # new `{ return CURLOPT_SSL_CTX_DATA; `}
546 # new `{ return CURLOPT_CONV_TO_NETWORK_FUNCTION; `}
547 # new `{ return CURLOPT_CONV_FROM_NETWORK_FUNCTION; `}
548 # new `{ return CURLOPT_CONV_FROM_UTF8_FUNCTION; `}
549 # new `{ return CURLOPT_INTERLEAVEFUNCTION; `}
550 # new `{ return CURLOPT_INTERLEAVEDATA; `}
551 # new `{ return CURLOPT_CHUNK_BGN_FUNCTION; `}
552 # new `{ return CURLOPT_CHUNK_END_FUNCTION; `}
553 # new `{ return CURLOPT_CHUNK_DATA; `}
554 # new `{ return CURLOPT_FNMATCH_FUNCTION; `}
555 # new `{ return CURLOPT_FNMATCH_DATA; `}
556
557 # Error Options
558
559 # new `{ return CURLOPT_ERRORBUFFER; `}
560 # new `{ return CURLOPT_STDERR; `}
561
562 # Fail on HTTP 4xx errors.
563 new fail_on_error `{ return CURLOPT_FAILONERROR; `}
564
565 # Networkd Options
566
567 # URL to work on.
568 new url `{ return CURLOPT_URL; `}
569
570 # new `{ return CURLOPT_PROTOCOLS; `}
571 # new `{ return CURLOPT_REDIR_PROTOCOLS; `}
572 # new `{ return CURLOPT_PROXY; `}
573 # new `{ return CURLOPT_PROXYPORT; `}
574 # new `{ return CURLOPT_PROXYTYPE; `}
575 # new `{ return CURLOPT_NOPROXY; `}
576 # new `{ return CURLOPT_HTTPPROXYTUNNEL; `}
577 # new `{ return CURLOPT_SOCKS5_GSSAPI_SERVICE; `}
578 # new `{ return CURLOPT_SOCKS5_GSSAPI_NEC; `}
579 # new `{ return CURLOPT_INTERFACE; `}
580 # new `{ return CURLOPT_LOCALPORT; `}
581 # new `{ return CURLOPT_LOCALPORTRANGE; `}
582 # new `{ return CURLOPT_DNS_CACHE_TIMEOUT; `}
583 # new `{ return CURLOPT_DNS_USE_GLOBAL_CACHE; `} /* DEPRECATED, do not use! */
584 # new `{ return CURLOPT_BUFFERSIZE; `}
585 # new `{ return CURLOPT_PORT; `}
586 # new `{ return CURLOPT_TCP_NODELAY; `}
587 # new `{ return CURLOPT_ADDRESS_SCOPE; `}
588 # new `{ return CURLOPT_TCP_KEEPALIVE; `}
589 # new `{ return CURLOPT_TCP_KEEPIDLE; `}
590 # new `{ return CURLOPT_TCP_KEEPINTVL; `}
591
592 # Names and Passwords Options
593
594 # new `{ return CURLOPT_NETRC; `}
595 # new `{ return CURLOPT_NETRC_FILE; `}
596 # new `{ return CURLOPT_USERPWD; `}
597 # new `{ return CURLOPT_PROXYUSERPWD; `}
598
599 new username `{ return CURLOPT_USERNAME; `}
600 new password `{ return CURLOPT_PASSWORD; `}
601
602 # new `{ return CURLOPT_PROXYUSERNAME; `}
603 # new `{ return CURLOPT_PROXYPASSWORD; `}
604 # new `{ return CURLOPT_HTTPAUTH; `}
605 # new `{ return CURLOPT_TLSAUTH_USERNAME; `}
606 # new `{ return CURLOPT_TLSAUTH_PASSWORD; `}
607 # new `{ return CURLOPT_PROXYAUTH; `}
608
609 # HTTP Options
610
611 # new `{ return CURLOPT_AUTOREFERER; `}
612
613 # Accept-Encoding and automatic decompressing data.
614 new accept_encoding `{ return CURLOPT_ACCEPT_ENCODING; `}
615
616 # Request Transfer-Encoding.
617 new transfert_encoding `{ return CURLOPT_TRANSFER_ENCODING; `}
618
619 # Follow HTTP redirects.
620 new follow_location `{ return CURLOPT_FOLLOWLOCATION; `}
621
622 # new `{ return CURLOPT_UNRESTRICTED_AUTH; `}
623 # new `{ return CURLOPT_MAXREDIRS; `}
624 # new `{ return CURLOPT_POSTREDIR; `}
625
626 # Issue a HTTP PUT request.
627 new put `{ return CURLOPT_PUT; `}
628
629 # Issue a HTTP POS request.
630 new post `{ return CURLOPT_POST; `}
631
632 # Send a POST with this data.
633 new postfields `{ return CURLOPT_POSTFIELDS; `}
634
635 # new `{ return CURLOPT_POSTFIELDSIZE; `}
636 # new `{ return CURLOPT_POSTFIELDSIZE_LARGE; `}
637 # new `{ return CURLOPT_COPYPOSTFIELDS; `}
638 # new `{ return CURLOPT_HTTPPOST; `}
639 # new `{ return CURLOPT_REFERER; `}
640
641 # User-Agent: header.
642 new user_agent `{ return CURLOPT_USERAGENT; `}
643
644 # Custom HTTP headers.
645 new httpheader `{ return CURLOPT_HTTPHEADER; `}
646
647 # new `{ return CURLOPT_HTTP200ALIASES; `}
648 # new `{ return CURLOPT_COOKIE; `}
649 # new `{ return CURLOPT_COOKIEFILE; `}
650 # new `{ return CURLOPT_COOKIEJAR; `}
651 # new `{ return CURLOPT_COOKIESESSION; `}
652 # new `{ return CURLOPT_COOKIELIST; `}
653
654 # Issue a HTTP GET request.
655 new get `{ return CURLOPT_HTTPGET; `}
656
657 # HTTP version to use.
658 new http_version `{ return CURLOPT_HTTP_VERSION; `}
659
660 # new `{ return CURLOPT_IGNORE_CONTENT_LENGTH; `}
661 # new `{ return CURLOPT_HTTP_CONTENT_DECODING; `}
662 # new `{ return CURLOPT_HTTP_TRANSFER_DECODING; `}
663
664 # SMTP Options
665
666 # Address of the sender.
667 new mail_from `{ return CURLOPT_MAIL_FROM; `}
668
669 # Address of the recipients.
670 new mail_rcpt `{ return CURLOPT_MAIL_RCPT; `}
671
672 # new `{ return CURLOPT_MAIL_AUTH; `}
673
674 # TFTP Options
675
676 # new `{ return CURLOPT_TFTP_BLKSIZE; `}
677
678 # FTP Options
679
680 # new `{ return CURLOPT_FTPPORT; `}
681 # new `{ return CURLOPT_QUOTE; `}
682 # new `{ return CURLOPT_POSTQUOTE; `}
683 # new `{ return CURLOPT_PREQUOTE; `}
684
685 # List only.
686 new dir_list_only `{ return CURLOPT_DIRLISTONLY; `}
687
688 # Append to remote file.
689 new append `{ return CURLOPT_APPEND; `}
690
691 # new `{ return CURLOPT_FTP_USE_EPRT; `}
692 # new `{ return CURLOPT_FTP_USE_EPSV; `}
693 # new `{ return CURLOPT_FTP_USE_PRET; `}
694 # new `{ return CURLOPT_FTP_CREATE_MISSING_DIRS; `}
695 # new `{ return CURLOPT_FTP_RESPONSE_TIMEOUT; `}
696 # new `{ return CURLOPT_FTP_ALTERNATIVE_TO_USER; `}
697 # new `{ return CURLOPT_FTP_SKIP_PASV_IP; `}
698 # new `{ return CURLOPT_FTPSSLAUTH; `}
699 # new `{ return CURLOPT_FTP_SSL_CCC; `}
700 # new `{ return CURLOPT_FTP_ACCOUNT; `}
701 # new `{ return CURLOPT_FTP_FILEMETHOD; `}
702
703 # RTSP Options
704
705 # new `{ return CURLOPT_RTSP_REQUEST; `}
706 # new `{ return CURLOPT_RTSP_SESSION_ID; `}
707 # new `{ return CURLOPT_RTSP_STREAM_URI; `}
708 # new `{ return CURLOPT_RTSP_TRANSPORT; `}
709 # new `{ return CURLOPT_RTSP_CLIENT_CSEQ; `}
710 # new `{ return CURLOPT_RTSP_SERVER_CSEQ; `}
711
712 # Protocol Options
713
714 # Transfer data in text/ASCII format.
715 new transfert_text `{ return CURLOPT_TRANSFERTEXT; `}
716
717 # new `{ return CURLOPT_PROXY_TRANSFER_MODE; `}
718 # new `{ return CURLOPT_CRLF; `}
719 # new `{ return CURLOPT_RANGE; `}
720 # new `{ return CURLOPT_RESUME_FROM; `}
721 # new `{ return CURLOPT_RESUME_FROM_LARGE; `}
722
723 # Issue a custom request/method.
724 new custom_request `{ return CURLOPT_CUSTOMREQUEST; `}
725
726 # new `{ return CURLOPT_FILETIME; `}
727
728 # Do not get the body contents.
729 new no_body `{ return CURLOPT_NOBODY; `}
730
731 # new `{ return CURLOPT_INFILESIZE; `}
732 # new `{ return CURLOPT_INFILESIZE_LARGE; `}
733
734 # Upload data.
735 new upload `{ return CURLOPT_UPLOAD; `}
736
737 # new `{ return CURLOPT_MAXFILESIZE; `}
738 # new `{ return CURLOPT_MAXFILESIZE_LARGE; `}
739 # new `{ return CURLOPT_TIMECONDITION; `}
740 # new `{ return CURLOPT_TIMEVALUE; `}
741
742 # Connection Options
743
744 # new `{ return CURLOPT_TIMEOUT; `}
745 # new `{ return CURLOPT_TIMEOUT_MS; `}
746 # new `{ return CURLOPT_LOW_SPEED_LIMIT; `}
747 # new `{ return CURLOPT_LOW_SPEED_TIME; `}
748 # new `{ return CURLOPT_MAX_SEND_SPEED_LARGE; `}
749 # new `{ return CURLOPT_MAX_RECV_SPEED_LARGE; `}
750 # new `{ return CURLOPT_MAXCONNECTS; `}
751 # new `{ return CURLOPT_FRESH_CONNECT; `}
752 # new `{ return CURLOPT_FORBID_REUSE; `}
753 # new `{ return CURLOPT_CONNECTTIMEOUT; `}
754 # new `{ return CURLOPT_CONNECTTIMEOUT_MS; `}
755 # new `{ return CURLOPT_IPRESOLVE; `}
756 # new `{ return CURLOPT_CONNECT_ONLY; `}
757 # new `{ return CURLOPT_USE_SSL; `}
758 # new `{ return CURLOPT_RESOLVE; `}
759 # new `{ return CURLOPT_ACCEPTTIMEOUT_MS; `}
760
761 # SSL and Security Options
762
763 # new `{ return CURLOPT_SSLCERT; `}
764 # new `{ return CURLOPT_SSLCERTTYPE; `}
765 # new `{ return CURLOPT_SSLKEY; `}
766 # new `{ return CURLOPT_SSLKEYTYPE; `}
767 # new `{ return CURLOPT_KEYPASSWD; `}
768 # new `{ return CURLOPT_SSLENGINE; `}
769 # new `{ return CURLOPT_SSLENGINE_DEFAULT; `}
770 # new `{ return CURLOPT_SSLVERSION; `}
771 # new `{ return CURLOPT_SSL_VERIFYPEER; `}
772 # new `{ return CURLOPT_CAINFO; `}
773 # new `{ return CURLOPT_ISSUERCERT; `}
774 # new `{ return CURLOPT_CAPATH; `}
775 # new `{ return CURLOPT_CRLFILE; `}
776 # new `{ return CURLOPT_SSL_VERIFYHOST; `}
777 # new `{ return CURLOPT_CERTINFO; `}
778 # new `{ return CURLOPT_RANDOM_FILE; `}
779 # new `{ return CURLOPT_EGDSOCKET; `}
780 # new `{ return CURLOPT_SSL_CIPHER_LIST; `}
781 # new `{ return CURLOPT_SSL_SESSIONID_CACHE; `}
782 # new `{ return CURLOPT_SSL_OPTIONS; `}
783 # new `{ return CURLOPT_KRBLEVEL; `}
784 # new `{ return CURLOPT_GSSAPI_DELEGATION; `}
785
786 # SSH Options
787
788 # new `{ return CURLOPT_SSH_AUTH_TYPES; `}
789 # new `{ return CURLOPT_SSH_HOST_PUBLIC_KEY_MD5; `}
790 # new `{ return CURLOPT_SSH_PUBLIC_KEYFILE; `}
791 # new `{ return CURLOPT_SSH_PRIVATE_KEYFILE; `}
792 # new `{ return CURLOPT_SSH_KNOWNHOSTS; `}
793 # new `{ return CURLOPT_SSH_KEYFUNCTION; `}
794 # new `{ return CURLOPT_SSH_KEYDATA; `}
795
796 # Other Options
797
798 # new `{ return CURLOPT_PRIVATE; `}
799 # new `{ return CURLOPT_SHARE; `}
800 # new `{ return CURLOPT_NEW_FILE_PERMS; `}
801 # new `{ return CURLOPT_NEW_DIRECTORY_PERMS; `}
802
803 # TELNET Options
804
805 # new `{ return CURLOPT_TELNETOPTIONS; `}
806 end