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