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