61525a6c732f6386fb0030c30506b71417af84c9
[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
19
20 import pipeline
21
22 in "C header" `{
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <curl/curl.h>
26
27 typedef enum {
28 CURLcallbackTypeHeader,
29 CURLcallbackTypeBody,
30 CURLcallbackTypeStream,
31 CURLcallbackTypeRead,
32 } CURLcallbackType;
33
34 typedef struct {
35 CCurlCallbacks delegate;
36 CURLcallbackType type;
37 } CURLCallbackDatas;
38
39 typedef struct {
40 char *data;
41 int len;
42 int pos;
43 } CURLCallbackReadDatas;
44 `}
45
46 in "C body" `{
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 = new_String_copy_from_native(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 = new_String_copy_from_native(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 = new_String_from_cstring(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 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 (recv != NULL); `}
82 # Easy Clean / Release CURL instance
83 fun easy_clean `{ curl_easy_cleanup( recv ); `}
84 # Perform the transfer described by setted options
85 fun easy_perform:CURLCode `{ return curl_easy_perform( recv ); `}
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( recv, 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( recv, 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( recv, 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( recv, 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= `{
117 char *r = NULL;
118 CURLcode c = curl_easy_getinfo( recv, opt, &r);
119 if((c == CURLE_OK) && r != NULL){
120 String ro = new_String_copy_from_native(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( recv, 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( recv, 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( recv, 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, String::copy_from_native `{
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( recv, CURLOPT_READDATA, d);
195
196 `}
197 # Internal method used to configure callbacks in terms of given type
198 private fun i_register_callback(delegate: CCurlCallbacks, cbtype: CURLCallbackType):CURLCode is extern import CCurlCallbacks::header_callback, CCurlCallbacks::body_callback, CCurlCallbacks::stream_callback `{
199 CURLCallbackDatas *d = malloc(sizeof(CURLCallbackDatas));
200 CCurlCallbacks_incr_ref(delegate);
201 d->type = cbtype;
202 d->delegate = delegate;
203 CURLcode e;
204 switch(cbtype){
205 case CURLcallbackTypeHeader:
206 e = curl_easy_setopt( recv, CURLOPT_HEADERFUNCTION, &nit_curl_callback_func);
207 if(e != CURLE_OK) return e;
208 e = curl_easy_setopt( recv, CURLOPT_WRITEHEADER, d);
209 break;
210 case CURLcallbackTypeBody:
211 case CURLcallbackTypeStream:
212 e = curl_easy_setopt( recv, CURLOPT_WRITEFUNCTION, &nit_curl_callback_func);
213 if(e != CURLE_OK) return e;
214 e = curl_easy_setopt( recv, CURLOPT_WRITEDATA, d);
215 break;
216 case CURLcallbackTypeRead:
217 e = curl_easy_setopt( recv, CURLOPT_READFUNCTION, &nit_curl_callback_read_func);
218 default:
219 break;
220 }
221 return e;
222 `}
223 # Convert given string to URL encoded string
224 fun escape(url: String):String `{
225 char *orig_url, *encoded_url = NULL;
226 orig_url = String_to_cstring(url);
227 encoded_url = curl_easy_escape( recv, orig_url, strlen(orig_url));
228 String b_url = new_String_copy_from_native(encoded_url);
229 curl_free(encoded_url);
230 return b_url;
231 `}
232 end
233
234 # FILE Extern type, reproduce basic FILE I/O
235 extern OFile `{ FILE* `}
236 # Open / Create a file from given name
237 new open(str: NativeString) `{ return fopen(str, "wb"); `}
238 # Check for File validity
239 fun is_valid:Bool `{ return recv != NULL; `}
240 # Internal method to write to the current file
241 private fun n_write(buffer: NativeString, size: Int, count: Int):Int `{ return fwrite(buffer, size, count, recv); `}
242 # Write datas to the current file
243 fun write(buffer: String, size: Int, count: Int):Int
244 do
245 if is_valid == true then return n_write(buffer.to_cstring, size, count)
246 return 0
247 end
248 # Internal method to close the current file
249 private fun n_close:Int `{ return fclose(recv); `}
250 # Close the current file
251 fun close:Bool
252 do
253 if is_valid == true then return n_close == 0
254 return false
255 end
256 end
257
258 # Interface for internal information callbacks methods
259 interface CCurlCallbacks
260 fun header_callback(line: String) is abstract
261 fun body_callback(line: String) is abstract
262 fun stream_callback(buffer: String, size: Int, count: Int) is abstract
263 end
264
265 # Extern Type to reproduce Enum of available Callback type
266 extern CURLCallbackType `{ CURLcallbackType `}
267 new header `{ return CURLcallbackTypeHeader; `}
268 new body `{ return CURLcallbackTypeBody; `}
269 new stream `{ return CURLcallbackTypeStream; `}
270 new read `{ return CURLcallbackTypeRead; `}
271 fun to_i:Int `{ return recv; `}
272 end
273
274 # CURL Code binding and helpers
275 extern CURLCode `{ CURLcode `}
276 new unknown_option `{ return CURLE_UNKNOWN_OPTION; `}
277 new unsupported_protocol `{ return CURLE_UNSUPPORTED_PROTOCOL; `}
278 new ok `{ return CURLE_OK; `}
279 new failed_init `{ return CURLE_FAILED_INIT; `}
280 fun code:Int `{ return recv; `}
281 fun is_ok:Bool `{ return recv == CURLE_OK; `}
282 fun is_valid_protocol:Bool `{ return recv == CURLE_UNSUPPORTED_PROTOCOL; `}
283 fun is_valid_init:Bool `{ return recv == CURLE_FAILED_INIT; `}
284 fun to_i:Int do return code end
285 redef fun to_s `{
286 char *c = (char*)curl_easy_strerror(recv);
287 return new_String_copy_from_native(c);
288 `}
289 end
290
291 # Extern Type of the Linked list type of CURL
292 extern CURLSList `{ struct curl_slist * `}
293 # Empty constructor which allow us to avoid the use of Nit NULLABLE type
294 private new `{ return NULL; `}
295 # Constructor allow us to get list instancied by appending an element inside.
296 new with_str(s: String) import String::to_cstring `{
297 struct curl_slist *l = NULL;
298 l = curl_slist_append(l, String_to_cstring(s));
299 return l;
300 `}
301 # Check for initialization
302 fun is_init:Bool `{ return (recv != NULL); `}
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(recv, (char*)k);
307 `}
308 # Internal method to check for reachability of current data
309 private fun i_data_reachable(c: CURLSList):Bool `{ return (c != NULL && c->data != NULL); `}
310 # Internal method to check for reachability of next element
311 private fun i_next_reachable(c: CURLSList):Bool `{ return (c != NULL && c->next != NULL); `}
312 # Internal method to get current data
313 private fun i_data(c: CURLSList):String `{ return new_String_from_cstring(c->data); `}
314 # Internal method to get next element
315 private fun i_next(c: CURLSList):CURLSList `{ return c->next; `}
316 # Convert current low level List to an Array[String] object
317 fun to_a:Array[String]
318 do
319 var r = new Array[String]
320 var cursor = self
321 loop
322 if i_data_reachable(cursor) != true then break
323 r.add(i_data(cursor))
324 cursor = i_next(cursor)
325 end
326 return r
327 end
328 # Release allocated memory
329 fun destroy `{ curl_slist_free_all(recv); `}
330 end
331
332 redef class Collection[E]
333 # Convert Collection[String] to CURLSList
334 fun to_curlslist: CURLSList
335 do
336 assert collectionItemType: self isa Collection[String] else
337 print "Collection item must be strings."
338 end
339 var primList = new CURLSList.with_str(self.first)
340 for s in self.skip_head(1) do primList.append(s)
341 return primList
342 end
343 end
344
345 # Array Response type of CCurl::easy_getinfo method
346 class CURLInfoResponseArray
347 var response:Array[String] = new Array[String]
348 private var prim_response:CURLSList = new CURLSList
349 end
350
351 # Long Response type of CCurl::easy_getinfo method
352 class CURLInfoResponseLong
353 var response:Int=0
354 end
355
356 # Double Response type of CCurl::easy_getinfo method
357 class CURLInfoResponseDouble
358 var response:Int=0
359 end
360
361 # String Response type of CCurl:easy_getinfo method
362 class CURLInfoResponseString
363 var response:String = ""
364 end
365
366 # Reproduce Enum of available CURL SList information, used for CCurl::easy_getinfo
367 extern CURLInfoSList `{ CURLINFO `}
368 new ssl_engines `{ return CURLINFO_SSL_ENGINES; `}
369 new cookielist `{ return CURLINFO_COOKIELIST; `}
370 end
371
372 # Reproduce Enum of available CURL Long information, used for CCurl::easy_getinfo
373 extern CURLInfoLong `{ CURLINFO `}
374 new response_code `{ return CURLINFO_RESPONSE_CODE; `}
375 new header_size `{ return CURLINFO_HEADER_SIZE; `}
376 new http_connectcode `{ return CURLINFO_HTTP_CONNECTCODE; `}
377 new filetime `{ return CURLINFO_FILETIME; `}
378 new redirect_count `{ return CURLINFO_REDIRECT_COUNT; `}
379 new request_size `{ return CURLINFO_REQUEST_SIZE; `}
380 new ssl_verifyresult `{ return CURLINFO_SSL_VERIFYRESULT; `}
381 new httpauth_avail `{ return CURLINFO_HTTPAUTH_AVAIL; `}
382 new proxyauth_avail `{ return CURLINFO_PROXYAUTH_AVAIL; `}
383 new os_errno `{ return CURLINFO_OS_ERRNO; `}
384 new num_connects `{ return CURLINFO_NUM_CONNECTS; `}
385 new primary_port `{ return CURLINFO_PRIMARY_PORT; `}
386 new local_port `{ return CURLINFO_LOCAL_PORT; `}
387 new lastsocket `{ return CURLINFO_LASTSOCKET; `}
388 new condition_unmet `{ return CURLINFO_CONDITION_UNMET; `}
389 new rtsp_client_cseq `{ return CURLINFO_RTSP_CLIENT_CSEQ; `}
390 new rtsp_server_cseq `{ return CURLINFO_RTSP_SERVER_CSEQ; `}
391 new rtsp_cseq_recv `{ return CURLINFO_RTSP_CSEQ_RECV; `}
392 end
393
394 # Reproduce Enum of available CURL Double information, used for CCurl::easy_getinfo
395 extern CURLInfoDouble `{ CURLINFO `}
396 new total_time `{ return CURLINFO_TOTAL_TIME; `}
397 new namelookup_time `{ return CURLINFO_NAMELOOKUP_TIME; `}
398 new connect_time `{ return CURLINFO_CONNECT_TIME; `}
399 new appconnect_time `{ return CURLINFO_APPCONNECT_TIME; `}
400 new pretransfer_time `{ return CURLINFO_PRETRANSFER_TIME; `}
401 new starttransfer_time `{ return CURLINFO_STARTTRANSFER_TIME; `}
402 new redirect_time `{ return CURLINFO_REDIRECT_TIME; `}
403 new size_upload `{ return CURLINFO_SIZE_UPLOAD; `}
404 new size_download `{ return CURLINFO_SIZE_DOWNLOAD; `}
405 new speed_download `{ return CURLINFO_SPEED_DOWNLOAD; `}
406 new speed_upload `{ return CURLINFO_SPEED_UPLOAD; `}
407 new content_length_download `{ return CURLINFO_CONTENT_LENGTH_DOWNLOAD; `}
408 new content_length_upload `{ return CURLINFO_CONTENT_LENGTH_UPLOAD; `}
409 end
410
411 # Reproduce Enum of available CURL Chars information, used for CCurl::easy_getinfo
412 extern CURLInfoChars `{ CURLINFO `}
413 new content_type `{ return CURLINFO_CONTENT_TYPE; `}
414 new effective_url `{ return CURLINFO_EFFECTIVE_URL; `}
415 new redirect_url `{ return CURLINFO_REDIRECT_URL; `}
416 new primary_ip `{ return CURLINFO_PRIMARY_IP; `}
417 new local_ip `{ return CURLINFO_LOCAL_IP; `}
418 new ftp_entry_path `{ return CURLINFO_FTP_ENTRY_PATH; `}
419 new rtsp_session_id `{ return CURLINFO_RTSP_SESSION_ID; `}
420 new private_data `{ return CURLINFO_PRIVATE; `}
421 end
422
423 # Reproduce Enum of HTTP Status Code
424 extern CURLStatusCode `{ int `}
425 new proceed `{ return 100; `}
426 new switching_protocols `{ return 101; `}
427 new ok `{ return 200; `}
428 new created `{ return 201; `}
429 new accepted `{ return 202; `}
430 new non_authoritative_information `{ return 203; `}
431 new no_content `{ return 204; `}
432 new reset_content `{ return 205; `}
433 new partial_content `{ return 206; `}
434 new multiple_choices `{ return 300; `}
435 new moved_permanently `{ return 301; `}
436 new moved_temporarily `{ return 302; `}
437 new see_other `{ return 303; `}
438 new not_modified `{ return 304; `}
439 new use_proxy `{ return 305; `}
440 new bad_request `{ return 400; `}
441 new unauthorized `{ return 401; `}
442 new payment_required `{ return 402; `}
443 new forbidden `{ return 403; `}
444 new not_found `{ return 404; `}
445 new method_not_allowed `{ return 405; `}
446 new not_acceptable `{ return 406; `}
447 new proxy_authentication_required `{ return 407; `}
448 new request_timeout `{ return 408; `}
449 new conflict `{ return 409; `}
450 new gone `{ return 410; `}
451 new length_required `{ return 411; `}
452 new precondition_failed `{ return 412; `}
453 new request_entity_too_large `{ return 413; `}
454 new request_uri_too_large `{ return 414; `}
455 new unsupported_media_type `{ return 415; `}
456 new internal_server_error `{ return 500; `}
457 new not_implemented `{ return 501; `}
458 new bad_gateway `{ return 502; `}
459 new service_unavailable `{ return 503; `}
460 new gateway_timeout `{ return 504; `}
461 new http_version_not_supported `{ return 505; `}
462 fun to_i:Int `{ return recv; `}
463 end
464
465 # Reproduce Enum of CURL Options usable, used for CCurl::easy_setopt
466 extern CURLOption `{ CURLoption `}
467 new write_function `{ return CURLOPT_WRITEFUNCTION; `}
468 new write_data `{ return CURLOPT_WRITEDATA; `}
469 # new `{ return CURLOPT_FILE; `}
470 new url `{ return CURLOPT_URL; `}
471 # new `{ return CURLOPT_PORT; `}
472 # new `{ return CURLOPT_PROXY; `}
473 # new `{ return CURLOPT_USERPWD; `}
474 # new `{ return CURLOPT_PROXYUSERPWD; `}
475 # new `{ return CURLOPT_RANGE; `}
476 # new `{ return CURLOPT_INFILE; `}
477 # new `{ return CURLOPT_ERRORBUFFER; `}
478 # new `{ return CURLOPT_WRITEFUNCTION; `}
479 # new `{ return CURLOPT_READFUNCTION; `}
480 # new `{ return CURLOPT_TIMEOUT; `}
481 # new `{ return CURLOPT_INFILESIZE; `}
482 new postfields `{ return CURLOPT_POSTFIELDS; `}
483 # new `{ return CURLOPT_REFERER; `}
484 # new `{ return CURLOPT_FTPPORT; `}
485 # new `{ return CURLOPT_USERAGENT; `}
486 # new `{ return CURLOPT_LOW_SPEED_LIMIT; `}
487 # new `{ return CURLOPT_LOW_SPEED_TIME; `}
488 # new `{ return CURLOPT_RESUME_FROM; `}
489 # new `{ return CURLOPT_COOKIE; `}
490 new httpheader `{ return CURLOPT_HTTPHEADER; `}
491 # new `{ return CURLOPT_HTTPPOST; `}
492 # new `{ return CURLOPT_SSLCERT; `}
493 # new `{ return CURLOPT_KEYPASSWD; `}
494 # new `{ return CURLOPT_CRLF; `}
495 # new `{ return CURLOPT_QUOTE; `}
496 # new `{ return CURLOPT_WRITEHEADER; `}
497 # new `{ return CURLOPT_COOKIEFILE; `}
498 # new `{ return CURLOPT_SSLVERSION; `}
499 # new `{ return CURLOPT_TIMECONDITION; `}
500 # new `{ return CURLOPT_TIMEVALUE; `}
501 # new `{ return CURLOPT_CUSTOMREQUEST; `}
502 # new `{ return CURLOPT_STDERR; `}
503 # new `{ return CURLOPT_POSTQUOTE; `}
504 # new `{ return CURLOPT_WRITEINFO; `} /* DEPRECATED, do not use! */
505 new verbose `{ return CURLOPT_VERBOSE; `} # talk a lot
506 new header `{ return CURLOPT_HEADER; `} # throw the header out too
507 new no_progress `{ return CURLOPT_NOPROGRESS; `} # shut off the progress meter
508 new no_body `{ return CURLOPT_NOBODY; `} # use HEAD to get http document
509 new fail_on_error `{ return CURLOPT_FAILONERROR; `} # no output on http error codes >= 300
510 new upload `{ return CURLOPT_UPLOAD; `} # this is an upload
511 new post `{ return CURLOPT_POST; `} # HTTP POST method
512 new dir_list_only `{ return CURLOPT_DIRLISTONLY; `} # bare names when listing directories
513 new append `{ return CURLOPT_APPEND; `} # Append instead of overwrite on upload!
514 # new `{ return CURLOPT_NETRC; `}
515 new follow_location `{ return CURLOPT_FOLLOWLOCATION; `} # use Location: Luke!
516 new transfert_text `{ return CURLOPT_TRANSFERTEXT; `} # transfer data in text/ASCII format
517 new put `{ return CURLOPT_PUT; `} # HTTP PUT */
518 # new `{ return CURLOPT_PROGRESSFUNCTION; `}
519 # new `{ return CURLOPT_PROGRESSDATA; `}
520 # new `{ return CURLOPT_AUTOREFERER; `}
521 # new `{ return CURLOPT_PROXYPORT; `}
522 # new `{ return CURLOPT_POSTFIELDSIZE; `}
523 # new `{ return CURLOPT_HTTPPROXYTUNNEL; `}
524 # new `{ return CURLOPT_INTERFACE; `}
525 # new `{ return CURLOPT_KRBLEVEL; `}
526 # new `{ return CURLOPT_SSL_VERIFYPEER; `}
527 # new `{ return CURLOPT_CAINFO; `}
528 # new `{ return CURLOPT_MAXREDIRS; `}
529 # new `{ return CURLOPT_FILETIME; `}
530 # new `{ return CURLOPT_TELNETOPTIONS; `}
531 # new `{ return CURLOPT_MAXCONNECTS; `}
532 # new `{ return CURLOPT_CLOSEPOLICY; `} /* DEPRECATED, do not use! */
533 # new `{ return CURLOPT_FRESH_CONNECT; `}
534 # new `{ return CURLOPT_FORBID_REUSE; `}
535 # new `{ return CURLOPT_RANDOM_FILE; `}
536 # new `{ return CURLOPT_EGDSOCKET; `}
537 # new `{ return CURLOPT_CONNECTTIMEOUT; `}
538 # new `{ return CURLOPT_HEADERFUNCTION; `}
539 # new `{ return CURLOPT_HTTPGET; `}
540 # new `{ return CURLOPT_SSL_VERIFYHOST; `}
541 # new `{ return CURLOPT_COOKIEJAR; `}
542 # new `{ return CURLOPT_SSL_CIPHER_LIST; `}
543 # new `{ return CURLOPT_HTTP_VERSION; `}
544 # new `{ return CURLOPT_FTP_USE_EPSV; `}
545 # new `{ return CURLOPT_SSLCERTTYPE; `}
546 # new `{ return CURLOPT_SSLKEY; `}
547 # new `{ return CURLOPT_SSLKEYTYPE; `}
548 # new `{ return CURLOPT_SSLENGINE; `}
549 # new `{ return CURLOPT_SSLENGINE_DEFAULT; `}
550 # new `{ return CURLOPT_DNS_USE_GLOBAL_CACHE; `} /* DEPRECATED, do not use! */
551 # new `{ return CURLOPT_DNS_CACHE_TIMEOUT; `}
552 # new `{ return CURLOPT_PREQUOTE; `}
553 # new `{ return CURLOPT_DEBUGFUNCTION; `}
554 # new `{ return CURLOPT_DEBUGDATA; `}
555 # new `{ return CURLOPT_COOKIESESSION; `}
556 # new `{ return CURLOPT_CAPATH; `}
557 # new `{ return CURLOPT_BUFFERSIZE; `}
558 # new `{ return CURLOPT_NOSIGNAL; `}
559 # new `{ return CURLOPT_SHARE; `}
560 # new `{ return CURLOPT_PROXYTYPE; `}
561 # new `{ return CURLOPT_ACCEPT_ENCODING; `}
562 # new `{ return CURLOPT_PRIVATE; `}
563 # new `{ return CURLOPT_HTTP200ALIASES; `}
564 # new `{ return CURLOPT_UNRESTRICTED_AUTH; `}
565 # new `{ return CURLOPT_FTP_USE_EPRT; `}
566 # new `{ return CURLOPT_HTTPAUTH; `}
567 # new `{ return CURLOPT_SSL_CTX_FUNCTION; `}
568 # new `{ return CURLOPT_SSL_CTX_DATA; `}
569 # new `{ return CURLOPT_FTP_CREATE_MISSING_DIRS; `}
570 # new `{ return CURLOPT_PROXYAUTH; `}
571 # new `{ return CURLOPT_FTP_RESPONSE_TIMEOUT; `}
572 # new `{ return CURLOPT_IPRESOLVE; `}
573 # new `{ return CURLOPT_MAXFILESIZE; `}
574 # new `{ return CURLOPT_INFILESIZE_LARGE; `}
575 # new `{ return CURLOPT_RESUME_FROM_LARGE; `}
576 # new `{ return CURLOPT_MAXFILESIZE_LARGE; `}
577 # new `{ return CURLOPT_NETRC_FILE; `}
578 # new `{ return CURLOPT_USE_SSL; `}
579 # new `{ return CURLOPT_POSTFIELDSIZE_LARGE; `}
580 # new `{ return CURLOPT_TCP_NODELAY; `}
581 # new `{ return CURLOPT_FTPSSLAUTH; `}
582 # new `{ return CURLOPT_IOCTLFUNCTION; `}
583 # new `{ return CURLOPT_IOCTLDATA; `}
584 # new `{ return CURLOPT_FTP_ACCOUNT; `}
585 # new `{ return CURLOPT_COOKIELIST; `}
586 # new `{ return CURLOPT_IGNORE_CONTENT_LENGTH; `}
587 # new `{ return CURLOPT_FTP_SKIP_PASV_IP; `}
588 # new `{ return CURLOPT_FTP_FILEMETHOD; `}
589 # new `{ return CURLOPT_LOCALPORT; `}
590 # new `{ return CURLOPT_LOCALPORTRANGE; `}
591 # new `{ return CURLOPT_CONNECT_ONLY; `}
592 # new `{ return CURLOPT_CONV_FROM_NETWORK_FUNCTION; `}
593 # new `{ return CURLOPT_CONV_TO_NETWORK_FUNCTION; `}
594 # new `{ return CURLOPT_CONV_FROM_UTF8_FUNCTION; `}
595 # new `{ return CURLOPT_MAX_SEND_SPEED_LARGE; `}
596 # new `{ return CURLOPT_MAX_RECV_SPEED_LARGE; `}
597 # new `{ return CURLOPT_FTP_ALTERNATIVE_TO_USER; `}
598 # new `{ return CURLOPT_SOCKOPTFUNCTION; `}
599 # new `{ return CURLOPT_SOCKOPTDATA; `}
600 # new `{ return CURLOPT_SSL_SESSIONID_CACHE; `}
601 # new `{ return CURLOPT_SSH_AUTH_TYPES; `}
602 # new `{ return CURLOPT_SSH_PUBLIC_KEYFILE; `}
603 # new `{ return CURLOPT_SSH_PRIVATE_KEYFILE; `}
604 # new `{ return CURLOPT_FTP_SSL_CCC; `}
605 # new `{ return CURLOPT_TIMEOUT_MS; `}
606 # new `{ return CURLOPT_CONNECTTIMEOUT_MS; `}
607 # new `{ return CURLOPT_HTTP_TRANSFER_DECODING; `}
608 # new `{ return CURLOPT_HTTP_CONTENT_DECODING; `}
609 # new `{ return CURLOPT_NEW_FILE_PERMS; `}
610 # new `{ return CURLOPT_NEW_DIRECTORY_PERMS; `}
611 # new `{ return CURLOPT_POSTREDIR; `}
612 # new `{ return CURLOPT_SSH_HOST_PUBLIC_KEY_MD5; `}
613 # new `{ return CURLOPT_OPENSOCKETFUNCTION; `}
614 # new `{ return CURLOPT_OPENSOCKETDATA; `}
615 # new `{ return CURLOPT_COPYPOSTFIELDS; `}
616 # new `{ return CURLOPT_PROXY_TRANSFER_MODE; `}
617 # new `{ return CURLOPT_SEEKFUNCTION; `}
618 # new `{ return CURLOPT_SEEKDATA; `}
619 # new `{ return CURLOPT_CRLFILE; `}
620 # new `{ return CURLOPT_ISSUERCERT; `}
621 # new `{ return CURLOPT_ADDRESS_SCOPE; `}
622 # new `{ return CURLOPT_CERTINFO; `}
623 new username `{ return CURLOPT_USERNAME; `}
624 new password `{ return CURLOPT_PASSWORD; `}
625 # new `{ return CURLOPT_PROXYUSERNAME; `}
626 # new `{ return CURLOPT_PROXYPASSWORD; `}
627 # new `{ return CURLOPT_NOPROXY; `}
628 # new `{ return CURLOPT_TFTP_BLKSIZE; `}
629 # new `{ return CURLOPT_SOCKS5_GSSAPI_SERVICE; `}
630 # new `{ return CURLOPT_SOCKS5_GSSAPI_NEC; `}
631 # new `{ return CURLOPT_PROTOCOLS; `}
632 # new `{ return CURLOPT_REDIR_PROTOCOLS; `}
633 # new `{ return CURLOPT_SSH_KNOWNHOSTS; `}
634 # new `{ return CURLOPT_SSH_KEYFUNCTION; `}
635 # new `{ return CURLOPT_SSH_KEYDATA; `}
636 new mail_from `{ return CURLOPT_MAIL_FROM; `}
637 new mail_rcpt `{ return CURLOPT_MAIL_RCPT; `}
638 # new `{ return CURLOPT_FTP_USE_PRET; `}
639 # new `{ return CURLOPT_RTSP_REQUEST; `}
640 # new `{ return CURLOPT_RTSP_SESSION_ID; `}
641 # new `{ return CURLOPT_RTSP_STREAM_URI; `}
642 # new `{ return CURLOPT_RTSP_TRANSPORT; `}
643 # new `{ return CURLOPT_RTSP_CLIENT_CSEQ; `}
644 # new `{ return CURLOPT_RTSP_SERVER_CSEQ; `}
645 # new `{ return CURLOPT_INTERLEAVEDATA; `}
646 # new `{ return CURLOPT_INTERLEAVEFUNCTION; `}
647 # new `{ return CURLOPT_WILDCARDMATCH; `}
648 # new `{ return CURLOPT_CHUNK_BGN_FUNCTION; `}
649 # new `{ return CURLOPT_CHUNK_END_FUNCTION; `}
650 # new `{ return CURLOPT_FNMATCH_FUNCTION; `}
651 # new `{ return CURLOPT_CHUNK_DATA; `}
652 # new `{ return CURLOPT_FNMATCH_DATA; `}
653 # new `{ return CURLOPT_RESOLVE; `}
654 # new `{ return CURLOPT_TLSAUTH_USERNAME; `}
655 # new `{ return CURLOPT_TLSAUTH_PASSWORD; `}
656 # new `{ return CURLOPT_TLSAUTH_TYPE; `}
657 # new `{ return CURLOPT_TRANSFER_ENCODING; `}
658 # new `{ return CURLOPT_CLOSESOCKETFUNCTION; `}
659 # new `{ return CURLOPT_CLOSESOCKETDATA; `}
660 # new `{ return CURLOPT_GSSAPI_DELEGATION; `}
661 # new `{ return CURLOPT_DNS_SERVERS; `}
662 # new `{ return CURLOPT_ACCEPTTIMEOUT_MS; `}
663 # new `{ return CURLOPT_TCP_KEEPALIVE; `}
664 # new `{ return CURLOPT_TCP_KEEPIDLE; `}
665 # new `{ return CURLOPT_TCP_KEEPINTVL; `}
666 # new `{ return CURLOPT_SSL_OPTIONS; `}
667 # new `{ return CURLOPT_MAIL_AUTH; `}
668 end