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