lib/curl: replace the `C` prefix by `Native`
[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 standard::file
21 import standard
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 NativeString
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 CURLInfoResponseString
117 do
118 var answ = new CURLInfoResponseString
119 if not native_getinfo_chars(opt, answ).is_ok then return null
120 return answ
121 end
122
123 # Internal method used to get String object information initially knowns as C Chars type
124 private fun native_getinfo_chars(opt: CURLInfoChars, res: CURLInfoResponseString): CURLCode import CURLInfoResponseString.response=, NativeString.to_s_with_copy `{
125 char *r = NULL;
126 CURLcode c = curl_easy_getinfo( self, opt, &r);
127 if((c == CURLE_OK) && r != NULL){
128 String ro = NativeString_to_s_with_copy(r);
129 CURLInfoResponseString_response__assign( res, ro);
130 }
131 return c;
132 `}
133
134 # Request Long internal information from the CURL session
135 fun easy_getinfo_long(opt: CURLInfoLong): nullable CURLInfoResponseLong
136 do
137 var answ = new CURLInfoResponseLong
138 if not native_getinfo_long(opt, answ).is_ok then return null
139 return answ
140 end
141
142 # Internal method used to get Int object information initially knowns as C Long type
143 private fun native_getinfo_long(opt: CURLInfoLong, res: CURLInfoResponseLong): CURLCode import CURLInfoResponseLong.response= `{
144 long *r = NULL;
145 r = malloc(sizeof(long));
146 CURLcode c = curl_easy_getinfo( self, opt, r);
147 if((c == CURLE_OK) && r != NULL) CURLInfoResponseLong_response__assign( res, *r);
148 free(r);
149 return c;
150 `}
151
152 # Request Double internal information from the CURL session
153 fun easy_getinfo_double(opt: CURLInfoDouble): nullable CURLInfoResponseDouble
154 do
155 var answ = new CURLInfoResponseDouble
156 if not native_getinfo_double(opt, answ).is_ok then return null
157 return answ
158 end
159
160 # Internal method used to get Int object information initially knowns as C Double type
161 private fun native_getinfo_double(opt: CURLInfoDouble, res: CURLInfoResponseDouble): CURLCode import CURLInfoResponseDouble.response= `{
162 double *r = NULL;
163 r = malloc(sizeof(double));
164 CURLcode c = curl_easy_getinfo( self, opt, r);
165 if((c == CURLE_OK) && r != NULL) CURLInfoResponseDouble_response__assign( res, *r);
166 free(r);
167 return c;
168 `}
169
170 # Request SList internal information from the CURL session
171 fun easy_getinfo_slist(opt: CURLInfoSList): nullable CURLInfoResponseArray
172 do
173 var answ = new CURLInfoResponseArray
174 if not native_getinfo_slist(opt, answ).is_ok then return null
175 answ.response = answ.prim_response.to_a
176 answ.prim_response.destroy
177 return answ
178 end
179
180 # Internal method used to get Array[String] object information initially knowns as C SList type
181 private fun native_getinfo_slist(opt: CURLInfoSList, res: CURLInfoResponseArray): CURLCode import CURLInfoResponseArray.prim_response= `{
182 struct curl_slist* csl = NULL;
183 CURLcode ce = curl_easy_getinfo( self, opt, &csl);
184 CURLInfoResponseArray_prim_response__assign(res, csl);
185 return ce;
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 NativeString.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)&NativeString_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 NativeString.native_callback_body `{
221 CURLcode e;
222 NativeCurlCallbacks_incr_ref(delegate);
223
224 e = curl_easy_setopt(self, CURLOPT_WRITEFUNCTION, (curl_write_callback)&NativeString_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 NativeString.native_callback_stream `{
234 CURLcode e;
235 NativeCurlCallbacks_incr_ref(delegate);
236
237 e = curl_easy_setopt(self, CURLOPT_WRITEFUNCTION, (curl_write_callback)&NativeString_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 NativeString.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, NativeString.to_s_with_copy `{
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 = NativeString_to_s_with_copy(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 NativeString.to_s_with_copy `{
283 char *c = (char*)curl_easy_strerror(self);
284 return NativeString_to_s_with_copy(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 NativeString.to_s `{ return NativeString_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 var primList = new CURLSList.with_str(self.first)
346 var is_first = true
347 for s in self do
348 if not is_first then primList.append(s)
349 is_first = false
350 end
351 return primList
352 end
353 end
354
355 # Array Response type of NativeCurl.easy_getinfo method
356 class CURLInfoResponseArray
357 var response: Array[String] = new Array[String]
358 private var prim_response: CURLSList = new CURLSList
359 end
360
361 # Long Response type of NativeCurl.easy_getinfo method
362 class CURLInfoResponseLong
363 var response = 0
364 end
365
366 # Double Response type of NativeCurl.easy_getinfo method
367 class CURLInfoResponseDouble
368 var response = 0
369 end
370
371 # String Response type of NativeCurl::easy_getinfo method
372 class CURLInfoResponseString
373 var response = ""
374 end
375
376 # Reproduce Enum of available CURL SList information, used for NativeCurl.easy_getinfo
377 extern class CURLInfoSList `{ CURLINFO `}
378 new ssl_engines `{ return CURLINFO_SSL_ENGINES; `}
379 new cookielist `{ return CURLINFO_COOKIELIST; `}
380 end
381
382 # Reproduce Enum of available CURL Long information, used for NativeCurl.easy_getinfo
383 extern class CURLInfoLong `{ CURLINFO `}
384 new response_code `{ return CURLINFO_RESPONSE_CODE; `}
385 new header_size `{ return CURLINFO_HEADER_SIZE; `}
386 new http_connectcode `{ return CURLINFO_HTTP_CONNECTCODE; `}
387 new filetime `{ return CURLINFO_FILETIME; `}
388 new redirect_count `{ return CURLINFO_REDIRECT_COUNT; `}
389 new request_size `{ return CURLINFO_REQUEST_SIZE; `}
390 new ssl_verifyresult `{ return CURLINFO_SSL_VERIFYRESULT; `}
391 new httpauth_avail `{ return CURLINFO_HTTPAUTH_AVAIL; `}
392 new proxyauth_avail `{ return CURLINFO_PROXYAUTH_AVAIL; `}
393 new os_errno `{ return CURLINFO_OS_ERRNO; `}
394 new num_connects `{ return CURLINFO_NUM_CONNECTS; `}
395 new primary_port `{ return CURLINFO_PRIMARY_PORT; `}
396 new local_port `{ return CURLINFO_LOCAL_PORT; `}
397 new lastsocket `{ return CURLINFO_LASTSOCKET; `}
398 new condition_unmet `{ return CURLINFO_CONDITION_UNMET; `}
399 new rtsp_client_cseq `{ return CURLINFO_RTSP_CLIENT_CSEQ; `}
400 new rtsp_server_cseq `{ return CURLINFO_RTSP_SERVER_CSEQ; `}
401 new rtsp_cseq_self `{ return CURLINFO_RTSP_CSEQ_RECV; `}
402 end
403
404 # Reproduce Enum of available CURL Double information, used for NativeCurl.easy_getinfo
405 extern class CURLInfoDouble `{ CURLINFO `}
406 new total_time `{ return CURLINFO_TOTAL_TIME; `}
407 new namelookup_time `{ return CURLINFO_NAMELOOKUP_TIME; `}
408 new connect_time `{ return CURLINFO_CONNECT_TIME; `}
409 new appconnect_time `{ return CURLINFO_APPCONNECT_TIME; `}
410 new pretransfer_time `{ return CURLINFO_PRETRANSFER_TIME; `}
411 new starttransfer_time `{ return CURLINFO_STARTTRANSFER_TIME; `}
412 new redirect_time `{ return CURLINFO_REDIRECT_TIME; `}
413 new size_upload `{ return CURLINFO_SIZE_UPLOAD; `}
414 new size_download `{ return CURLINFO_SIZE_DOWNLOAD; `}
415 new speed_download `{ return CURLINFO_SPEED_DOWNLOAD; `}
416 new speed_upload `{ return CURLINFO_SPEED_UPLOAD; `}
417 new content_length_download `{ return CURLINFO_CONTENT_LENGTH_DOWNLOAD; `}
418 new content_length_upload `{ return CURLINFO_CONTENT_LENGTH_UPLOAD; `}
419 end
420
421 # Reproduce Enum of available CURL Chars information, used for NativeCurl.easy_getinfo
422 extern class CURLInfoChars `{ CURLINFO `}
423 new content_type `{ return CURLINFO_CONTENT_TYPE; `}
424 new effective_url `{ return CURLINFO_EFFECTIVE_URL; `}
425 new redirect_url `{ return CURLINFO_REDIRECT_URL; `}
426 new primary_ip `{ return CURLINFO_PRIMARY_IP; `}
427 new local_ip `{ return CURLINFO_LOCAL_IP; `}
428 new ftp_entry_path `{ return CURLINFO_FTP_ENTRY_PATH; `}
429 new rtsp_session_id `{ return CURLINFO_RTSP_SESSION_ID; `}
430 new private_data `{ return CURLINFO_PRIVATE; `}
431 end
432
433 # Reproduce Enum of HTTP Status Code
434 extern class CURLStatusCode `{ int `}
435 new proceed `{ return 100; `}
436 new switching_protocols `{ return 101; `}
437 new ok `{ return 200; `}
438 new created `{ return 201; `}
439 new accepted `{ return 202; `}
440 new non_authoritative_information `{ return 203; `}
441 new no_content `{ return 204; `}
442 new reset_content `{ return 205; `}
443 new partial_content `{ return 206; `}
444 new multiple_choices `{ return 300; `}
445 new moved_permanently `{ return 301; `}
446 new moved_temporarily `{ return 302; `}
447 new see_other `{ return 303; `}
448 new not_modified `{ return 304; `}
449 new use_proxy `{ return 305; `}
450 new bad_request `{ return 400; `}
451 new unauthorized `{ return 401; `}
452 new payment_required `{ return 402; `}
453 new forbidden `{ return 403; `}
454 new not_found `{ return 404; `}
455 new method_not_allowed `{ return 405; `}
456 new not_acceptable `{ return 406; `}
457 new proxy_authentication_required `{ return 407; `}
458 new request_timeout `{ return 408; `}
459 new conflict `{ return 409; `}
460 new gone `{ return 410; `}
461 new length_required `{ return 411; `}
462 new precondition_failed `{ return 412; `}
463 new request_entity_too_large `{ return 413; `}
464 new request_uri_too_large `{ return 414; `}
465 new unsupported_media_type `{ return 415; `}
466 new internal_server_error `{ return 500; `}
467 new not_implemented `{ return 501; `}
468 new bad_gateway `{ return 502; `}
469 new service_unavailable `{ return 503; `}
470 new gateway_timeout `{ return 504; `}
471 new http_version_not_supported `{ return 505; `}
472 fun to_i: Int `{ return self; `}
473 end
474
475 # Reproduce Enum of CURL Options usable, used for NativeCurl.easy_setopt
476 extern class CURLOption `{ CURLoption `}
477
478 # Behavior options
479
480 # Display verbose information.
481 new verbose `{ return CURLOPT_VERBOSE; `}
482
483 # Include the header in the body output.
484 new header `{ return CURLOPT_HEADER; `}
485
486 # Shut off the progress meter.
487 new no_progress `{ return CURLOPT_NOPROGRESS; `}
488
489 # Do not install signal handlers.
490 new no_signal `{ return CURLOPT_NOSIGNAL; `}
491
492 # Transfer multiple files according to a file name pattern.
493 new wild_card_match `{ return CURLOPT_WILDCARDMATCH; `}
494
495 # Callback Options
496
497 # Callback for writing data.
498 new write_function `{ return CURLOPT_WRITEFUNCTION; `}
499
500 # Data pointer to pass to the write callback.
501 new write_data `{ return CURLOPT_WRITEDATA; `}
502
503 # new `{ return CURLOPT_READFUNCTION; `}
504 # new `{ return CURLOPT_READDATA; `}
505 # new `{ return CURLOPT_IOCTLFUNCTION; `}
506 # new `{ return CURLOPT_IOCTLDATA; `}
507 # new `{ return CURLOPT_SEEKFUNCTION; `}
508 # new `{ return CURLOPT_SEEKDATA; `}
509 # new `{ return CURLOPT_SOCKOPTFUNCTION; `}
510 # new `{ return CURLOPT_SOCKOPTDATA; `}
511 # new `{ return CURLOPT_OPENSOCKETFUNCTION; `}
512 # new `{ return CURLOPT_OPENSOCKETDATA; `}
513 # new `{ return CURLOPT_CLOSESOCKETFUNCTION; `}
514 # new `{ return CURLOPT_CLOSESOCKETDATA; `}
515 # new `{ return CURLOPT_PROGRESSFUNCTION; `}
516 # new `{ return CURLOPT_PROGRESSDATA; `}
517 # new `{ return CURLOPT_HEADERFUNCTION; `}
518 # new `{ return CURLOPT_DEBUGFUNCTION; `}
519 # new `{ return CURLOPT_DEBUGDATA; `}
520 # new `{ return CURLOPT_SSL_CTX_FUNCTION; `}
521 # new `{ return CURLOPT_SSL_CTX_DATA; `}
522 # new `{ return CURLOPT_CONV_TO_NETWORK_FUNCTION; `}
523 # new `{ return CURLOPT_CONV_FROM_NETWORK_FUNCTION; `}
524 # new `{ return CURLOPT_CONV_FROM_UTF8_FUNCTION; `}
525 # new `{ return CURLOPT_INTERLEAVEFUNCTION; `}
526 # new `{ return CURLOPT_INTERLEAVEDATA; `}
527 # new `{ return CURLOPT_CHUNK_BGN_FUNCTION; `}
528 # new `{ return CURLOPT_CHUNK_END_FUNCTION; `}
529 # new `{ return CURLOPT_CHUNK_DATA; `}
530 # new `{ return CURLOPT_FNMATCH_FUNCTION; `}
531 # new `{ return CURLOPT_FNMATCH_DATA; `}
532
533 # Error Options
534
535 # new `{ return CURLOPT_ERRORBUFFER; `}
536 # new `{ return CURLOPT_STDERR; `}
537
538 # Fail on HTTP 4xx errors.
539 new fail_on_error `{ return CURLOPT_FAILONERROR; `}
540
541 # Networkd Options
542
543 # URL to work on.
544 new url `{ return CURLOPT_URL; `}
545
546 # new `{ return CURLOPT_PROTOCOLS; `}
547 # new `{ return CURLOPT_REDIR_PROTOCOLS; `}
548 # new `{ return CURLOPT_PROXY; `}
549 # new `{ return CURLOPT_PROXYPORT; `}
550 # new `{ return CURLOPT_PROXYTYPE; `}
551 # new `{ return CURLOPT_NOPROXY; `}
552 # new `{ return CURLOPT_HTTPPROXYTUNNEL; `}
553 # new `{ return CURLOPT_SOCKS5_GSSAPI_SERVICE; `}
554 # new `{ return CURLOPT_SOCKS5_GSSAPI_NEC; `}
555 # new `{ return CURLOPT_INTERFACE; `}
556 # new `{ return CURLOPT_LOCALPORT; `}
557 # new `{ return CURLOPT_LOCALPORTRANGE; `}
558 # new `{ return CURLOPT_DNS_CACHE_TIMEOUT; `}
559 # new `{ return CURLOPT_DNS_USE_GLOBAL_CACHE; `} /* DEPRECATED, do not use! */
560 # new `{ return CURLOPT_BUFFERSIZE; `}
561 # new `{ return CURLOPT_PORT; `}
562 # new `{ return CURLOPT_TCP_NODELAY; `}
563 # new `{ return CURLOPT_ADDRESS_SCOPE; `}
564 # new `{ return CURLOPT_TCP_KEEPALIVE; `}
565 # new `{ return CURLOPT_TCP_KEEPIDLE; `}
566 # new `{ return CURLOPT_TCP_KEEPINTVL; `}
567
568 # Names and Passwords Options
569
570 # new `{ return CURLOPT_NETRC; `}
571 # new `{ return CURLOPT_NETRC_FILE; `}
572 # new `{ return CURLOPT_USERPWD; `}
573 # new `{ return CURLOPT_PROXYUSERPWD; `}
574
575 new username `{ return CURLOPT_USERNAME; `}
576 new password `{ return CURLOPT_PASSWORD; `}
577
578 # new `{ return CURLOPT_PROXYUSERNAME; `}
579 # new `{ return CURLOPT_PROXYPASSWORD; `}
580 # new `{ return CURLOPT_HTTPAUTH; `}
581 # new `{ return CURLOPT_TLSAUTH_USERNAME; `}
582 # new `{ return CURLOPT_TLSAUTH_PASSWORD; `}
583 # new `{ return CURLOPT_PROXYAUTH; `}
584
585 # HTTP Options
586
587 # new `{ return CURLOPT_AUTOREFERER; `}
588
589 # Accept-Encoding and automatic decompressing data.
590 new accept_encoding `{ return CURLOPT_ACCEPT_ENCODING; `}
591
592 # Request Transfer-Encoding.
593 new transfert_encoding `{ return CURLOPT_TRANSFER_ENCODING; `}
594
595 # Follow HTTP redirects.
596 new follow_location `{ return CURLOPT_FOLLOWLOCATION; `}
597
598 # new `{ return CURLOPT_UNRESTRICTED_AUTH; `}
599 # new `{ return CURLOPT_MAXREDIRS; `}
600 # new `{ return CURLOPT_POSTREDIR; `}
601
602 # Issue a HTTP PUT request.
603 new put `{ return CURLOPT_PUT; `}
604
605 # Issue a HTTP POS request.
606 new post `{ return CURLOPT_POST; `}
607
608 # Send a POST with this data.
609 new postfields `{ return CURLOPT_POSTFIELDS; `}
610
611 # new `{ return CURLOPT_POSTFIELDSIZE; `}
612 # new `{ return CURLOPT_POSTFIELDSIZE_LARGE; `}
613 # new `{ return CURLOPT_COPYPOSTFIELDS; `}
614 # new `{ return CURLOPT_HTTPPOST; `}
615 # new `{ return CURLOPT_REFERER; `}
616
617 # User-Agent: header.
618 new user_agent `{ return CURLOPT_USERAGENT; `}
619
620 # Custom HTTP headers.
621 new httpheader `{ return CURLOPT_HTTPHEADER; `}
622
623 # new `{ return CURLOPT_HTTP200ALIASES; `}
624 # new `{ return CURLOPT_COOKIE; `}
625 # new `{ return CURLOPT_COOKIEFILE; `}
626 # new `{ return CURLOPT_COOKIEJAR; `}
627 # new `{ return CURLOPT_COOKIESESSION; `}
628 # new `{ return CURLOPT_COOKIELIST; `}
629
630 # Issue a HTTP GET request.
631 new get `{ return CURLOPT_HTTPGET; `}
632
633 # HTTP version to use.
634 new http_version `{ return CURLOPT_HTTP_VERSION; `}
635
636 # new `{ return CURLOPT_IGNORE_CONTENT_LENGTH; `}
637 # new `{ return CURLOPT_HTTP_CONTENT_DECODING; `}
638 # new `{ return CURLOPT_HTTP_TRANSFER_DECODING; `}
639
640 # SMTP Options
641
642 # Address of the sender.
643 new mail_from `{ return CURLOPT_MAIL_FROM; `}
644
645 # Address of the recipients.
646 new mail_rcpt `{ return CURLOPT_MAIL_RCPT; `}
647
648 # new `{ return CURLOPT_MAIL_AUTH; `}
649
650 # TFTP Options
651
652 # new `{ return CURLOPT_TFTP_BLKSIZE; `}
653
654 # FTP Options
655
656 # new `{ return CURLOPT_FTPPORT; `}
657 # new `{ return CURLOPT_QUOTE; `}
658 # new `{ return CURLOPT_POSTQUOTE; `}
659 # new `{ return CURLOPT_PREQUOTE; `}
660
661 # List only.
662 new dir_list_only `{ return CURLOPT_DIRLISTONLY; `}
663
664 # Append to remote file.
665 new append `{ return CURLOPT_APPEND; `}
666
667 # new `{ return CURLOPT_FTP_USE_EPRT; `}
668 # new `{ return CURLOPT_FTP_USE_EPSV; `}
669 # new `{ return CURLOPT_FTP_USE_PRET; `}
670 # new `{ return CURLOPT_FTP_CREATE_MISSING_DIRS; `}
671 # new `{ return CURLOPT_FTP_RESPONSE_TIMEOUT; `}
672 # new `{ return CURLOPT_FTP_ALTERNATIVE_TO_USER; `}
673 # new `{ return CURLOPT_FTP_SKIP_PASV_IP; `}
674 # new `{ return CURLOPT_FTPSSLAUTH; `}
675 # new `{ return CURLOPT_FTP_SSL_CCC; `}
676 # new `{ return CURLOPT_FTP_ACCOUNT; `}
677 # new `{ return CURLOPT_FTP_FILEMETHOD; `}
678
679 # RTSP Options
680
681 # new `{ return CURLOPT_RTSP_REQUEST; `}
682 # new `{ return CURLOPT_RTSP_SESSION_ID; `}
683 # new `{ return CURLOPT_RTSP_STREAM_URI; `}
684 # new `{ return CURLOPT_RTSP_TRANSPORT; `}
685 # new `{ return CURLOPT_RTSP_CLIENT_CSEQ; `}
686 # new `{ return CURLOPT_RTSP_SERVER_CSEQ; `}
687
688 # Protocol Options
689
690 # Transfer data in text/ASCII format.
691 new transfert_text `{ return CURLOPT_TRANSFERTEXT; `}
692
693 # new `{ return CURLOPT_PROXY_TRANSFER_MODE; `}
694 # new `{ return CURLOPT_CRLF; `}
695 # new `{ return CURLOPT_RANGE; `}
696 # new `{ return CURLOPT_RESUME_FROM; `}
697 # new `{ return CURLOPT_RESUME_FROM_LARGE; `}
698
699 # Issue a custom request/method.
700 new custom_request `{ return CURLOPT_CUSTOMREQUEST; `}
701
702 # new `{ return CURLOPT_FILETIME; `}
703
704 # Do not get the body contents.
705 new no_body `{ return CURLOPT_NOBODY; `}
706
707 # new `{ return CURLOPT_INFILESIZE; `}
708 # new `{ return CURLOPT_INFILESIZE_LARGE; `}
709
710 # Upload data.
711 new upload `{ return CURLOPT_UPLOAD; `}
712
713 # new `{ return CURLOPT_MAXFILESIZE; `}
714 # new `{ return CURLOPT_MAXFILESIZE_LARGE; `}
715 # new `{ return CURLOPT_TIMECONDITION; `}
716 # new `{ return CURLOPT_TIMEVALUE; `}
717
718 # Connection Options
719
720 # new `{ return CURLOPT_TIMEOUT; `}
721 # new `{ return CURLOPT_TIMEOUT_MS; `}
722 # new `{ return CURLOPT_LOW_SPEED_LIMIT; `}
723 # new `{ return CURLOPT_LOW_SPEED_TIME; `}
724 # new `{ return CURLOPT_MAX_SEND_SPEED_LARGE; `}
725 # new `{ return CURLOPT_MAX_RECV_SPEED_LARGE; `}
726 # new `{ return CURLOPT_MAXCONNECTS; `}
727 # new `{ return CURLOPT_FRESH_CONNECT; `}
728 # new `{ return CURLOPT_FORBID_REUSE; `}
729 # new `{ return CURLOPT_CONNECTTIMEOUT; `}
730 # new `{ return CURLOPT_CONNECTTIMEOUT_MS; `}
731 # new `{ return CURLOPT_IPRESOLVE; `}
732 # new `{ return CURLOPT_CONNECT_ONLY; `}
733 # new `{ return CURLOPT_USE_SSL; `}
734 # new `{ return CURLOPT_RESOLVE; `}
735 # new `{ return CURLOPT_ACCEPTTIMEOUT_MS; `}
736
737 # SSL and Security Options
738
739 # new `{ return CURLOPT_SSLCERT; `}
740 # new `{ return CURLOPT_SSLCERTTYPE; `}
741 # new `{ return CURLOPT_SSLKEY; `}
742 # new `{ return CURLOPT_SSLKEYTYPE; `}
743 # new `{ return CURLOPT_KEYPASSWD; `}
744 # new `{ return CURLOPT_SSLENGINE; `}
745 # new `{ return CURLOPT_SSLENGINE_DEFAULT; `}
746 # new `{ return CURLOPT_SSLVERSION; `}
747 # new `{ return CURLOPT_SSL_VERIFYPEER; `}
748 # new `{ return CURLOPT_CAINFO; `}
749 # new `{ return CURLOPT_ISSUERCERT; `}
750 # new `{ return CURLOPT_CAPATH; `}
751 # new `{ return CURLOPT_CRLFILE; `}
752 # new `{ return CURLOPT_SSL_VERIFYHOST; `}
753 # new `{ return CURLOPT_CERTINFO; `}
754 # new `{ return CURLOPT_RANDOM_FILE; `}
755 # new `{ return CURLOPT_EGDSOCKET; `}
756 # new `{ return CURLOPT_SSL_CIPHER_LIST; `}
757 # new `{ return CURLOPT_SSL_SESSIONID_CACHE; `}
758 # new `{ return CURLOPT_SSL_OPTIONS; `}
759 # new `{ return CURLOPT_KRBLEVEL; `}
760 # new `{ return CURLOPT_GSSAPI_DELEGATION; `}
761
762 # SSH Options
763
764 # new `{ return CURLOPT_SSH_AUTH_TYPES; `}
765 # new `{ return CURLOPT_SSH_HOST_PUBLIC_KEY_MD5; `}
766 # new `{ return CURLOPT_SSH_PUBLIC_KEYFILE; `}
767 # new `{ return CURLOPT_SSH_PRIVATE_KEYFILE; `}
768 # new `{ return CURLOPT_SSH_KNOWNHOSTS; `}
769 # new `{ return CURLOPT_SSH_KEYFUNCTION; `}
770 # new `{ return CURLOPT_SSH_KEYDATA; `}
771
772 # Other Options
773
774 # new `{ return CURLOPT_PRIVATE; `}
775 # new `{ return CURLOPT_SHARE; `}
776 # new `{ return CURLOPT_NEW_FILE_PERMS; `}
777 # new `{ return CURLOPT_NEW_DIRECTORY_PERMS; `}
778
779 # TELNET Options
780
781 # new `{ return CURLOPT_TELNETOPTIONS; `}
782 end