travis: + OCaml 4.07
[ocurl.git] / curl.mli
blobd5433c44e9ee6579947b51c5dbc3a160f075c9c8
1 (*
2 * curl.mli
4 * Copyright (c) 2003-2008, Lars Nilsson, <lars@quantumchamaeleon.com>
5 * Copyright (c) 2009, ygrek, <ygrek@autistici.org>
6 *)
8 (** libcurl wrapper *)
10 (** {2 Types} *)
12 type t
14 type curlCode =
15 | CURLE_OK
16 | CURLE_UNSUPPORTED_PROTOCOL
17 | CURLE_FAILED_INIT
18 | CURLE_URL_MALFORMAT
19 | CURLE_URL_MALFORMAT_USER
20 | CURLE_COULDNT_RESOLVE_PROXY
21 | CURLE_COULDNT_RESOLVE_HOST
22 | CURLE_COULDNT_CONNECT
23 | CURLE_FTP_WEIRD_SERVER_REPLY
24 | CURLE_FTP_ACCESS_DENIED
25 | CURLE_FTP_USER_PASSWORD_INCORRECT
26 | CURLE_FTP_WEIRD_PASS_REPLY
27 | CURLE_FTP_WEIRD_USER_REPLY
28 | CURLE_FTP_WEIRD_PASV_REPLY
29 | CURLE_FTP_WEIRD_227_FORMAT
30 | CURLE_FTP_CANT_GET_HOST
31 | CURLE_FTP_CANT_RECONNECT
32 | CURLE_FTP_COULDNT_SET_BINARY
33 | CURLE_PARTIAL_FILE
34 | CURLE_FTP_COULDNT_RETR_FILE
35 | CURLE_FTP_WRITE_ERROR
36 | CURLE_FTP_QUOTE_ERROR
37 | CURLE_HTTP_NOT_FOUND
38 | CURLE_WRITE_ERROR
39 | CURLE_MALFORMAT_USER
40 | CURLE_FTP_COULDNT_STOR_FILE
41 | CURLE_READ_ERROR
42 | CURLE_OUT_OF_MEMORY
43 | CURLE_OPERATION_TIMEOUTED
44 | CURLE_FTP_COULDNT_SET_ASCII
45 | CURLE_FTP_PORT_FAILED
46 | CURLE_FTP_COULDNT_USE_REST
47 | CURLE_FTP_COULDNT_GET_SIZE
48 | CURLE_HTTP_RANGE_ERROR
49 | CURLE_HTTP_POST_ERROR
50 | CURLE_SSL_CONNECT_ERROR
51 | CURLE_FTP_BAD_DOWNLOAD_RESUME
52 | CURLE_FILE_COULDNT_READ_FILE
53 | CURLE_LDAP_CANNOT_BIND
54 | CURLE_LDAP_SEARCH_FAILED
55 | CURLE_LIBRARY_NOT_FOUND
56 | CURLE_FUNCTION_NOT_FOUND
57 | CURLE_ABORTED_BY_CALLBACK
58 | CURLE_BAD_FUNCTION_ARGUMENT
59 | CURLE_BAD_CALLING_ORDER
60 | CURLE_HTTP_PORT_FAILED
61 | CURLE_BAD_PASSWORD_ENTERED
62 | CURLE_TOO_MANY_REDIRECTS
63 | CURLE_UNKNOWN_TELNET_OPTION
64 | CURLE_TELNET_OPTION_SYNTAX
65 | CURLE_OBSOLETE
66 | CURLE_SSL_PEER_CERTIFICATE
67 | CURLE_GOT_NOTHING
68 | CURLE_SSL_ENGINE_NOTFOUND
69 | CURLE_SSL_ENGINE_SETFAILED
70 | CURLE_SEND_ERROR
71 | CURLE_RECV_ERROR
72 | CURLE_SHARE_IN_USE
73 | CURLE_SSL_CERTPROBLEM
74 | CURLE_SSL_CIPHER
75 | CURLE_SSL_CACERT
76 | CURLE_BAD_CONTENT_ENCODING
77 | CURLE_LDAP_INVALID_URL
78 | CURLE_FILESIZE_EXCEEDED
79 | CURLE_USE_SSL_FAILED
80 | CURLE_SEND_FAIL_REWIND
81 | CURLE_SSL_ENGINE_INITFAILED
82 | CURLE_LOGIN_DENIED
83 | CURLE_TFTP_NOTFOUND
84 | CURLE_TFTP_PERM
85 | CURLE_REMOTE_DISK_FULL
86 | CURLE_TFTP_ILLEGAL
87 | CURLE_TFTP_UNKNOWNID
88 | CURLE_REMOTE_FILE_EXISTS
89 | CURLE_TFTP_NOSUCHUSER
90 | CURLE_CONV_FAILED
91 | CURLE_CONV_REQD
92 | CURLE_SSL_CACERT_BADFILE
93 | CURLE_REMOTE_FILE_NOT_FOUND
94 | CURLE_SSH
95 | CURLE_SSL_SHUTDOWN_FAILED
96 | CURLE_AGAIN
98 exception CurlException of (curlCode * int * string)
100 (** exception raised when trying to use options missing from libcurl headers,
101 argument is the option name *)
102 exception NotImplemented of string
104 type curlNETRCOption =
105 | CURL_NETRC_OPTIONAL
106 | CURL_NETRC_IGNORED
107 | CURL_NETRC_REQUIRED
109 type curlEncoding =
110 | CURL_ENCODING_NONE (* identity *)
111 | CURL_ENCODING_DEFLATE (* deflate *)
112 | CURL_ENCODING_GZIP (* gzip *)
113 | CURL_ENCODING_ANY (* all supported encodings *)
115 type curlContentType =
116 | DEFAULT
117 | CONTENTTYPE of string
119 type curlHTTPPost =
120 | CURLFORM_CONTENT of string * string * curlContentType
121 | CURLFORM_FILECONTENT of string * string * curlContentType
122 | CURLFORM_FILE of string * string * curlContentType
123 | CURLFORM_BUFFER of string * string * string * curlContentType
126 type curlHTTPPost =
127 | CURLFORM_COPYNAME of string
128 | CURLFORM_PTRNAME of string
129 | CURLFORM_NAMELENGTH of int
130 | CURLFORM_COPYCONTENTS of string
131 | CURLFORM_PTRCONTENTS of string
132 | CURLFORM_FILE of string
133 | CURLFORM_FILECONTENT of string
134 | CURLFORM_CONTENTSLENGTH of int
135 | CURLFORM_CONTENTTYPE of string
138 type curlSSLVersion =
139 | SSLVERSION_DEFAULT (** attempt to figure out the remote SSL protocol version *)
140 | SSLVERSION_TLSv1 (** TLSv1.x *)
141 | SSLVERSION_SSLv2 (** SSLv2 *)
142 | SSLVERSION_SSLv3 (** SSLv3 *)
143 | SSLVERSION_TLSv1_0 (** Added in libcurl 7.34.0, will request TLSv1.x in previous versions *)
144 | SSLVERSION_TLSv1_1 (** Added in libcurl 7.34.0, will request TLSv1.x in previous versions *)
145 | SSLVERSION_TLSv1_2 (** Added in libcurl 7.34.0, will request TLSv1.x in previous versions *)
146 | SSLVERSION_TLSv1_3 (** Added in libcurl 7.52.0, will request TLSv1.x in previous versions *)
148 type curlTimeCondition =
149 | TIMECOND_NONE (** since 0.6.1 *)
150 | TIMECOND_IFMODSINCE
151 | TIMECOND_IFUNMODSINCE
152 | TIMECOND_LASTMOD (** since 0.6.1 *)
154 type curlKRB4Level =
155 | KRB4_NONE
156 | KRB4_CLEAR
157 | KRB4_SAFE
158 | KRB4_CONFIDENTIAL
159 | KRB4_PRIVATE
161 type curlClosePolicy =
162 | CLOSEPOLICY_OLDEST
163 | CLOSEPOLICY_LEAST_RECENTLY_USED
165 type curlSSLVerifyHost =
166 | SSLVERIFYHOST_NONE (** connection succeeds regardless of the names in the certificate *)
167 | SSLVERIFYHOST_EXISTENCE (** deprecated, equivalent to SSLVERIFYHOST_HOSTNAME *)
168 | SSLVERIFYHOST_HOSTNAME (** certificate must indicate the matching hostname, or the connection fails *)
170 type curlHTTPVersion =
171 | HTTP_VERSION_NONE (** libcurl will make the best choice *)
172 | HTTP_VERSION_1_0 (** please use HTTP 1.0 *)
173 | HTTP_VERSION_1_1 (** please use HTTP 1.1 *)
174 | HTTP_VERSION_2 (** please use HTTP 2 *)
175 | HTTP_VERSION_2TLS (** use version 2 for HTTPS, version 1.1 for HTTP *)
177 type curlDebugType =
178 | DEBUGTYPE_TEXT
179 | DEBUGTYPE_HEADER_IN
180 | DEBUGTYPE_HEADER_OUT
181 | DEBUGTYPE_DATA_IN
182 | DEBUGTYPE_DATA_OUT
183 | DEBUGTYPE_SSL_DATA_IN
184 | DEBUGTYPE_SSL_DATA_OUT
185 | DEBUGTYPE_END
187 type curlAuth =
188 | CURLAUTH_BASIC
189 | CURLAUTH_DIGEST
190 | CURLAUTH_GSSNEGOTIATE
191 | CURLAUTH_NTLM
192 | CURLAUTH_ANY
193 | CURLAUTH_ANYSAFE
195 type curlIPResolve =
196 | IPRESOLVE_WHATEVER
197 | IPRESOLVE_V4
198 | IPRESOLVE_V6
200 type curlFTPSSL =
201 | FTPSSL_NONE
202 | FTPSSL_TRY
203 | FTPSSL_CONTROL
204 | FTPSSL_ALL
206 type curlFTPSSLAuth =
207 | FTPAUTH_DEFAULT
208 | FTPAUTH_SSL
209 | FTPAUTH_TLS
211 type curlIOCmd =
212 | IOCMD_NOP
213 | IOCMD_RESTARTREAD
215 type curlIOErr =
216 | IOE_OK
217 | IOE_UNKNOWNCMD
218 | IOE_FAILRESTART
220 type curlSeekResult =
221 | SEEKFUNC_OK
222 | SEEKFUNC_FAIL
223 | SEEKFUNC_CANTSEEK
225 type curlFTPMethod =
226 | FTPMETHOD_DEFAULT
227 | FTPMETHOD_MULTICWD
228 | FTPMETHOD_NOCWD
229 | FTPMETHOD_SINGLECWD
231 type curlSSHAuthTypes =
232 | SSHAUTH_ANY
233 | SSHAUTH_PUBLICKEY
234 | SSHAUTH_PASSWORD
235 | SSHAUTH_HOST
236 | SSHAUTH_KEYBOARD
238 type curlFTPSSLCCC =
239 | FTPSSL_CCC_NONE
240 | FTPSSL_CCC_PASSIVE
241 | FTPSSL_CCC_ACTIVE
243 type curlSeek =
244 | SEEK_SET
245 | SEEK_CUR
246 | SEEK_END
248 type curlProxyType =
249 | CURLPROXY_HTTP
250 | CURLPROXY_HTTP_1_0 (** since libcurl 7.19.4 *)
251 | CURLPROXY_SOCKS4 (** since libcurl 7.15.2 *)
252 | CURLPROXY_SOCKS5
253 | CURLPROXY_SOCKS4A (** since libcurl 7.18.0 *)
254 | CURLPROXY_SOCKS5_HOSTNAME (** since libcurl 7.18.0 *)
256 type curlMIMEPartData =
257 | CURLMIME_DATA of string
258 | CURLMIME_FILEDATA of string
260 type curlMIMEEncoding =
261 | CURLMIME_8BIT
262 | CURLMIME_BINARY
263 | CURLMIME_7BIT
264 | CURLMIME_QUOTEDPRINTABLE
265 | CURLMIME_BASE64
266 | CURLMIME_NONE
268 type curlMIMEPart =
270 encoding: curlMIMEEncoding;
271 headers: string list;
272 subparts: curlMIMEPart list;
273 data: curlMIMEPartData;
276 type curlKHMatch =
277 | CURLKHMATCH_OK
278 | CURLKHMATCH_MISMATCH of string
279 (** Argument consists of the base64-encoded public key of the remote host as
280 as found in the "known hosts" file **)
281 | CURLKHMATCH_MISSING
283 type curlKHStat =
284 | CURLKHSTAT_FINE_ADD_TO_FILE
285 | CURLKHSTAT_FINE
286 | CURLKHSTAT_REJECT
287 | CURLKHSTAT_DEFER
289 (** Protocols to enable (via CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS) *)
290 type curlProto =
291 | CURLPROTO_ALL (** enable everything *)
292 | CURLPROTO_HTTP
293 | CURLPROTO_HTTPS
294 | CURLPROTO_FTP
295 | CURLPROTO_FTPS
296 | CURLPROTO_SCP
297 | CURLPROTO_SFTP
298 | CURLPROTO_TELNET
299 | CURLPROTO_LDAP
300 | CURLPROTO_LDAPS
301 | CURLPROTO_DICT
302 | CURLPROTO_FILE
303 | CURLPROTO_TFTP
304 | CURLPROTO_IMAP
305 | CURLPROTO_IMAPS
306 | CURLPROTO_POP3
307 | CURLPROTO_POP3S
308 | CURLPROTO_SMTP
309 | CURLPROTO_SMTPS
310 | CURLPROTO_RTSP
311 | CURLPROTO_RTMP
312 | CURLPROTO_RTMPT
313 | CURLPROTO_RTMPE
314 | CURLPROTO_RTMPTE
315 | CURLPROTO_RTMPS
316 | CURLPROTO_RTMPTS
317 | CURLPROTO_GOPHER
319 (** if flag is not supported by libcurl - enabling it does nothing *)
320 type curlPostRedir =
321 | REDIR_POST_ALL
322 | REDIR_POST_301
323 | REDIR_POST_302
324 | REDIR_POST_303 (** added in libcurl 7.26.0 *)
326 type curlOption =
327 | CURLOPT_WRITEFUNCTION of (string -> int)
328 | CURLOPT_READFUNCTION of (int -> string)
329 | CURLOPT_INFILESIZE of int
330 | CURLOPT_URL of string
331 | CURLOPT_PROXY of string
332 | CURLOPT_PROXYPORT of int
333 | CURLOPT_HTTPPROXYTUNNEL of bool
334 | CURLOPT_VERBOSE of bool
335 | CURLOPT_HEADER of bool
336 | CURLOPT_NOPROGRESS of bool
337 | CURLOPT_NOSIGNAL of bool
338 | CURLOPT_NOBODY of bool
339 | CURLOPT_FAILONERROR of bool
340 | CURLOPT_UPLOAD of bool
341 | CURLOPT_POST of bool
342 | CURLOPT_FTPLISTONLY of bool
343 | CURLOPT_FTPAPPEND of bool
344 | CURLOPT_NETRC of curlNETRCOption
345 | CURLOPT_ENCODING of curlEncoding
346 | CURLOPT_FOLLOWLOCATION of bool
347 | CURLOPT_TRANSFERTEXT of bool
348 | CURLOPT_PUT of bool
349 | CURLOPT_USERPWD of string
350 | CURLOPT_PROXYUSERPWD of string
351 | CURLOPT_RANGE of string
352 | CURLOPT_ERRORBUFFER of string ref
353 | CURLOPT_TIMEOUT of int
354 | CURLOPT_POSTFIELDS of string
355 | CURLOPT_POSTFIELDSIZE of int
356 | CURLOPT_REFERER of string
357 | CURLOPT_USERAGENT of string
358 | CURLOPT_FTPPORT of string
359 | CURLOPT_LOWSPEEDLIMIT of int
360 | CURLOPT_LOWSPEEDTIME of int
361 | CURLOPT_RESUMEFROM of int
362 | CURLOPT_COOKIE of string
363 | CURLOPT_HTTPHEADER of string list
364 | CURLOPT_HTTPPOST of curlHTTPPost list
365 | CURLOPT_SSLCERT of string
366 | CURLOPT_SSLCERTTYPE of string
367 | CURLOPT_SSLCERTPASSWD of string
368 | CURLOPT_SSLKEY of string
369 | CURLOPT_SSLKEYTYPE of string
370 | CURLOPT_SSLKEYPASSWD of string
371 | CURLOPT_SSLENGINE of string
372 | CURLOPT_SSLENGINEDEFAULT of bool
373 | CURLOPT_CRLF of bool
374 | CURLOPT_QUOTE of string list
375 | CURLOPT_POSTQUOTE of string list
376 | CURLOPT_HEADERFUNCTION of (string -> int)
377 | CURLOPT_COOKIEFILE of string
378 | CURLOPT_SSLVERSION of curlSSLVersion
379 | CURLOPT_TIMECONDITION of curlTimeCondition
380 | CURLOPT_TIMEVALUE of int32
381 | CURLOPT_CUSTOMREQUEST of string
382 | CURLOPT_INTERFACE of string
383 | CURLOPT_KRB4LEVEL of curlKRB4Level
384 | CURLOPT_PROGRESSFUNCTION of (float -> float -> float -> float -> bool)
385 | CURLOPT_SSLVERIFYPEER of bool
386 | CURLOPT_CAINFO of string
387 | CURLOPT_CAPATH of string
388 | CURLOPT_FILETIME of bool
389 | CURLOPT_MAXREDIRS of int
390 | CURLOPT_MAXCONNECTS of int
391 | CURLOPT_CLOSEPOLICY of curlClosePolicy
392 | CURLOPT_FRESHCONNECT of bool
393 | CURLOPT_FORBIDREUSE of bool
394 | CURLOPT_RANDOMFILE of string
395 | CURLOPT_EGDSOCKET of string
396 | CURLOPT_CONNECTTIMEOUT of int
397 | CURLOPT_HTTPGET of bool
398 | CURLOPT_SSLVERIFYHOST of curlSSLVerifyHost
399 | CURLOPT_COOKIEJAR of string
400 | CURLOPT_SSLCIPHERLIST of string
401 | CURLOPT_HTTPVERSION of curlHTTPVersion
402 | CURLOPT_FTPUSEEPSV of bool
403 | CURLOPT_DNSCACHETIMEOUT of int
404 | CURLOPT_DNSUSEGLOBALCACHE of bool
405 | CURLOPT_DEBUGFUNCTION of (t -> curlDebugType -> string -> unit)
406 | CURLOPT_PRIVATE of string (** doesn't employ libcurl's CURLOPT_PRIVATE *)
407 | CURLOPT_HTTP200ALIASES of string list
408 | CURLOPT_UNRESTRICTEDAUTH of bool
409 | CURLOPT_FTPUSEEPRT of bool
410 | CURLOPT_HTTPAUTH of curlAuth list
411 | CURLOPT_FTPCREATEMISSINGDIRS of bool
412 | CURLOPT_PROXYAUTH of curlAuth list
413 | CURLOPT_FTPRESPONSETIMEOUT of int
414 | CURLOPT_IPRESOLVE of curlIPResolve
415 | CURLOPT_MAXFILESIZE of int32
416 | CURLOPT_INFILESIZELARGE of int64
417 | CURLOPT_RESUMEFROMLARGE of int64
418 | CURLOPT_MAXFILESIZELARGE of int64
419 | CURLOPT_NETRCFILE of string
420 | CURLOPT_FTPSSL of curlFTPSSL
421 | CURLOPT_POSTFIELDSIZELARGE of int64
422 | CURLOPT_TCPNODELAY of bool
423 | CURLOPT_FTPSSLAUTH of curlFTPSSLAuth
424 | CURLOPT_IOCTLFUNCTION of (t -> curlIOCmd -> curlIOErr)
425 | CURLOPT_FTPACCOUNT of string
426 | CURLOPT_COOKIELIST of string
427 | CURLOPT_IGNORECONTENTLENGTH of bool
428 | CURLOPT_FTPSKIPPASVIP of bool
429 | CURLOPT_FTPFILEMETHOD of curlFTPMethod
430 | CURLOPT_LOCALPORT of int
431 | CURLOPT_LOCALPORTRANGE of int
432 | CURLOPT_CONNECTONLY of bool
433 | CURLOPT_MAXSENDSPEEDLARGE of int64
434 | CURLOPT_MAXRECVSPEEDLARGE of int64
435 | CURLOPT_FTPALTERNATIVETOUSER of string
436 | CURLOPT_SSLSESSIONIDCACHE of bool
437 | CURLOPT_SSHAUTHTYPES of curlSSHAuthTypes list
438 | CURLOPT_SSHPUBLICKEYFILE of string
439 | CURLOPT_SSHPRIVATEKEYFILE of string
440 | CURLOPT_FTPSSLCCC of curlFTPSSLCCC
441 | CURLOPT_TIMEOUTMS of int
442 | CURLOPT_CONNECTTIMEOUTMS of int
443 | CURLOPT_HTTPTRANSFERDECODING of bool
444 | CURLOPT_HTTPCONTENTDECODING of bool
445 | CURLOPT_NEWFILEPERMS of int
446 | CURLOPT_NEWDIRECTORYPERMS of int
447 | CURLOPT_POST301 of bool
448 | CURLOPT_SSHHOSTPUBLICKEYMD5 of string
449 | CURLOPT_COPYPOSTFIELDS of string
450 | CURLOPT_PROXYTRANSFERMODE of bool
451 | CURLOPT_SEEKFUNCTION of (int64 -> curlSeek -> curlSeekResult)
452 | CURLOPT_AUTOREFERER of bool
453 | CURLOPT_OPENSOCKETFUNCTION of (Unix.file_descr -> unit)
454 | CURLOPT_PROXYTYPE of curlProxyType
455 | CURLOPT_PROTOCOLS of curlProto list
456 | CURLOPT_REDIR_PROTOCOLS of curlProto list
457 | CURLOPT_RESOLVE of string list
458 | CURLOPT_DNS_SERVERS of string
459 | CURLOPT_MAIL_FROM of string
460 | CURLOPT_MAIL_RCPT of string list
461 | CURLOPT_PIPEWAIT of bool
462 | CURLOPT_CERTINFO of bool
463 | CURLOPT_USERNAME of string
464 | CURLOPT_PASSWORD of string
465 | CURLOPT_LOGIN_OPTIONS of string
466 | CURLOPT_CONNECT_TO of string list
467 | CURLOPT_POSTREDIR of curlPostRedir list
468 | CURLOPT_MIMEPOST of curlMIMEPart list (* @since libcurl 7.56.0 *)
469 | CURLOPT_SSHKNOWNHOSTS of string
470 | CURLOPT_SSHKEYFUNCTION of (curlKHMatch -> string -> curlKHStat)
471 (** The second argument to the passed function consists of the raw bytes of
472 the public key sent by the remote host. If the function raises an
473 exception the key will be rejected, and the connection will fail.**)
475 type initOption =
476 | CURLINIT_GLOBALALL
477 | CURLINIT_GLOBALSSL
478 | CURLINIT_GLOBALWIN32
479 | CURLINIT_GLOBALNOTHING
481 type curlInfo =
482 | CURLINFO_EFFECTIVE_URL
483 | CURLINFO_HTTP_CODE
484 | CURLINFO_RESPONSE_CODE
485 | CURLINFO_TOTAL_TIME
486 | CURLINFO_NAMELOOKUP_TIME
487 | CURLINFO_CONNECT_TIME
488 | CURLINFO_PRETRANSFER_TIME
489 | CURLINFO_SIZE_UPLOAD
490 | CURLINFO_SIZE_DOWNLOAD
491 | CURLINFO_SPEED_DOWNLOAD
492 | CURLINFO_SPEED_UPLOAD
493 | CURLINFO_HEADER_SIZE
494 | CURLINFO_REQUEST_SIZE
495 | CURLINFO_SSL_VERIFYRESULT
496 | CURLINFO_FILETIME
497 | CURLINFO_CONTENT_LENGTH_DOWNLOAD
498 | CURLINFO_CONTENT_LENGTH_UPLOAD
499 | CURLINFO_STARTTRANSFER_TIME
500 | CURLINFO_CONTENT_TYPE
501 | CURLINFO_REDIRECT_TIME
502 | CURLINFO_REDIRECT_COUNT
503 | CURLINFO_PRIVATE (** returns value previously set with CURLOPT_PRIVATE, doesn't employ libcurl's CURLINFO_PRIVATE *)
504 | CURLINFO_HTTP_CONNECTCODE
505 | CURLINFO_HTTPAUTH_AVAIL
506 | CURLINFO_PROXYAUTH_AVAIL
507 | CURLINFO_OS_ERRNO
508 | CURLINFO_NUM_CONNECTS
509 | CURLINFO_SSL_ENGINES
510 | CURLINFO_COOKIELIST
511 | CURLINFO_LASTSOCKET
512 | CURLINFO_FTP_ENTRY_PATH
513 | CURLINFO_REDIRECT_URL
514 | CURLINFO_PRIMARY_IP
515 | CURLINFO_LOCAL_IP
516 | CURLINFO_LOCAL_PORT
517 | CURLINFO_CONDITION_UNMET
518 | CURLINFO_CERTINFO
520 type curlInfoResult =
521 | CURLINFO_String of string
522 | CURLINFO_Long of int
523 | CURLINFO_Double of float
524 | CURLINFO_StringList of string list
525 | CURLINFO_StringListList of string list list
527 type version_info = {
528 version : string;
529 number : int * int * int;
530 host : string;
531 features : string list;
532 ssl_version : string option;
533 libz_version : string option;
534 protocols : string list;
535 ares : string; (** starting from this field are optional features - may be empty/zero *)
536 ares_num : int;
537 libidn : string;
538 iconv_ver_num : int;
539 libssh_version : string;
542 type pauseOption = PAUSE_SEND | PAUSE_RECV | PAUSE_ALL
544 (** {2 curl_easy API} *)
546 val global_init : initOption -> unit
547 val global_cleanup : unit -> unit
548 val init : unit -> t
549 val reset : t -> unit
550 (** Reset [t] to the default state *)
551 val duphandle : t -> t [@@ocaml.deprecated "collect options and apply to fresh handle explicitly instead"]
552 (** Create the new handle, copying all the options from the supplied [t].
553 Note that it will also copy [set_writefunction] options and alike, as such both
554 handles (original and new one) will be referencing the same closures, potentially
555 sharing some state, which may lead to surprising results.
556 @deprecated collect options and apply to fresh handle explicitly instead, see also https://github.com/ygrek/ocurl/issues/31
558 val setopt : t -> curlOption -> unit
559 (** @raise NotImplemented for not implemented option *)
560 val perform : t -> unit
561 val cleanup : t -> unit
562 val getinfo : t -> curlInfo -> curlInfoResult
563 val escape : string -> string
564 val unescape : string -> string
565 val getdate : string -> float -> float
566 val version : unit -> string
567 val strerror : curlCode -> string
568 val int_of_curlCode : curlCode -> int
569 val curlCode_of_int : int -> curlCode option
570 (** same as [int_of_curlCode] *)
571 val errno : curlCode -> int
572 val version_info : unit -> version_info
573 val pause : t -> pauseOption list -> unit
575 (** {2 Set transfer options}
577 All callback functions shouldn't raise exceptions.
578 Any exception raised in callback function will be silently caught and discared,
579 and transfer will be aborted. *)
581 val set_writefunction : t -> (string -> int) -> unit
582 val set_readfunction : t -> (int -> string) -> unit
583 (** [readfunction n] should return string of length at most [n], otherwise
584 transfer will be aborted (as if with exception) *)
585 val set_infilesize : t -> int -> unit
586 val set_url : t -> string -> unit
587 val set_proxy : t -> string -> unit
588 val set_proxyport : t -> int -> unit
589 val set_httpproxytunnel : t -> bool -> unit
590 val set_verbose : t -> bool -> unit
591 val set_header : t -> bool -> unit
592 val set_noprogress : t -> bool -> unit
593 val set_nosignal : t -> bool -> unit
594 val set_nobody : t -> bool -> unit
595 val set_failonerror : t -> bool -> unit
596 val set_upload : t -> bool -> unit
597 val set_post : t -> bool -> unit
598 val set_ftplistonly : t -> bool -> unit
599 val set_ftpappend : t -> bool -> unit
600 val set_netrc : t -> curlNETRCOption -> unit
601 val set_encoding : t -> curlEncoding -> unit
602 val set_followlocation : t -> bool -> unit
603 val set_transfertext : t -> bool -> unit
604 val set_put : t -> bool -> unit
605 val set_userpwd : t -> string -> unit
606 val set_proxyuserpwd : t -> string -> unit
607 val set_range : t -> string -> unit
608 val set_errorbuffer : t -> string ref -> unit
609 val set_timeout : t -> int -> unit
610 val set_postfields : t -> string -> unit
611 val set_postfieldsize : t -> int -> unit
612 val set_referer : t -> string -> unit
613 val set_useragent : t -> string -> unit
614 val set_ftpport : t -> string -> unit
615 val set_lowspeedlimit : t -> int -> unit
616 val set_lowspeedtime : t -> int -> unit
617 val set_resumefrom : t -> int -> unit
618 val set_cookie : t -> string -> unit
619 val set_httpheader : t -> string list -> unit
620 val set_httppost : t -> curlHTTPPost list -> unit
621 val set_sslcert : t -> string -> unit
622 val set_sslcerttype : t -> string -> unit
623 val set_sslcertpasswd : t -> string -> unit
624 val set_sslkey : t -> string -> unit
625 val set_sslkeytype : t -> string -> unit
626 val set_sslkeypasswd : t -> string -> unit
627 val set_sslengine : t -> string -> unit
628 val set_sslenginedefault : t -> bool -> unit
629 val set_certinfo : t -> bool -> unit
630 val set_crlf : t -> bool -> unit
631 val set_quote : t -> string list -> unit
632 val set_postquote : t -> string list -> unit
633 val set_headerfunction: t -> (string -> int) -> unit
634 val set_cookiefile : t -> string -> unit
635 val set_sslversion : t -> curlSSLVersion -> unit
636 val set_timecondition : t -> curlTimeCondition -> unit
637 val set_timevalue : t -> int32 -> unit
638 val set_customrequest : t -> string -> unit
639 val set_interface : t -> string -> unit
640 val set_krb4level : t -> curlKRB4Level -> unit
641 val set_progressfunction : t -> (float -> float -> float -> float -> bool) -> unit
642 val set_sslverifypeer : t -> bool -> unit
643 val set_cainfo : t -> string -> unit
644 val set_capath : t -> string -> unit
645 val set_filetime : t -> bool -> unit
646 val set_maxredirs : t -> int -> unit
647 val set_maxconnects : t -> int -> unit
648 val set_closepolicy : t -> curlClosePolicy -> unit
649 val set_freshconnect : t -> bool -> unit
650 val set_forbidreuse : t -> bool -> unit
651 val set_randomfile : t -> string -> unit
652 val set_egdsocket : t -> string -> unit
653 val set_connecttimeout : t -> int -> unit
654 val set_httpget : t -> bool -> unit
655 val set_sslverifyhost : t -> curlSSLVerifyHost -> unit
656 val set_cookiejar : t -> string -> unit
657 val set_sslcipherlist : t -> string -> unit
658 val set_httpversion : t -> curlHTTPVersion -> unit
659 val set_ftpuseepsv : t -> bool -> unit
660 val set_dnscachetimeout : t -> int -> unit
661 val set_dnsuseglobalcache : t -> bool -> unit
662 val set_debugfunction : t -> (t -> curlDebugType -> string -> unit) -> unit
663 val set_private : t -> string -> unit
664 val set_http200aliases : t -> string list -> unit
665 val set_unrestrictedauth : t -> bool -> unit
666 val set_ftpuseeprt : t -> bool -> unit
667 val set_httpauth : t -> curlAuth list -> unit
668 val set_ftpcreatemissingdirs : t -> bool -> unit
669 val set_proxyauth : t -> curlAuth list -> unit
670 val set_ftpresponsetimeout : t -> int -> unit
671 val set_ipresolve : t -> curlIPResolve -> unit
672 val set_maxfilesize : t -> int32 -> unit
673 val set_infilesizelarge : t -> int64 -> unit
674 val set_resumefromlarge : t -> int64 -> unit
675 val set_maxfilesizelarge : t -> int64 -> unit
676 val set_netrcfile : t -> string -> unit
677 val set_ftpssl : t -> curlFTPSSL -> unit
678 val set_postfieldsizelarge : t -> int64 -> unit
679 val set_tcpnodelay : t -> bool -> unit
680 val set_ftpsslauth : t -> curlFTPSSLAuth -> unit
681 val set_ioctlfunction : t -> (t -> curlIOCmd -> curlIOErr) -> unit
682 val set_ftpaccount : t -> string -> unit
683 val set_cookielist : t -> string -> unit
684 val set_ignorecontentlength : t -> bool -> unit
685 val set_ftpskippasvip : t -> bool -> unit
686 val set_ftpfilemethod : t -> curlFTPMethod -> unit
687 val set_localport : t -> int -> unit
688 val set_localportrange : t -> int -> unit
689 val set_connectonly : t -> bool -> unit
690 val set_maxsendspeedlarge : t -> int64 -> unit
691 val set_maxrecvspeedlarge : t -> int64 -> unit
692 val set_ftpalternativetouser : t -> string -> unit
693 val set_sslsessionidcache : t -> bool -> unit
694 val set_sshauthtypes : t -> curlSSHAuthTypes list -> unit
695 val set_sshpublickeyfile : t -> string -> unit
696 val set_sshprivatekeyfile : t -> string -> unit
697 val set_ftpsslccc : t -> curlFTPSSLCCC -> unit
698 val set_timeoutms : t -> int -> unit
699 val set_connecttimeoutms : t -> int -> unit
700 val set_httptransferdecoding : t -> bool -> unit
701 val set_httpcontentdecoding : t -> bool -> unit
702 val set_newfileperms : t -> int -> unit
703 val set_newdirectoryperms : t -> int -> unit
704 val set_post301 : t -> bool -> unit
705 val set_sshhostpublickeymd5 : t -> string -> unit
706 val set_copypostfields : t -> string -> unit
707 val set_proxytransfermode : t -> bool -> unit
708 val set_seekfunction : t -> (int64 -> curlSeek -> curlSeekResult) -> unit
709 val set_autoreferer : t -> bool -> unit
710 val set_opensocketfunction : t -> (Unix.file_descr -> unit) -> unit
711 val set_proxytype : t -> curlProxyType -> unit
712 val set_protocols : t -> curlProto list -> unit
713 val set_redirprotocols : t -> curlProto list -> unit
715 (** [set_resolve t add del] adjusts builtin dns mapping
717 @param add is the (host,port,address) list to add to dns mapping
718 @param del is the (host,port) list to remove from mapping
720 val set_resolve : t -> (string * int * string) list -> (string * int) list -> unit
721 val set_dns_servers : t -> string list -> unit
722 val set_mailfrom : t -> string -> unit
723 val set_mailrcpt : t -> string list -> unit
724 val set_pipewait : t -> bool -> unit
725 val set_username : t -> string -> unit
726 (** @since 0.8.0 *)
727 val set_password : t -> string -> unit
728 (** @since 0.8.0 *)
729 val set_login_options : t -> string -> unit
730 (** @since 0.8.0 *)
731 val set_connect_to : t -> string list -> unit
732 (** @since 0.8.0 *)
733 val set_postredir : t -> curlPostRedir list -> unit
734 (** @since 0.8.1 *)
735 val set_mimepost : t -> curlMIMEPart list -> unit
736 (** @since 0.8.2 *)
738 val set_sshknownhosts : t -> string -> unit
739 val set_sshkeyfunction : t -> (curlKHMatch -> string -> curlKHStat) -> unit
741 (** {2 Get transfer properties} *)
743 val get_effectiveurl : t -> string
744 val get_redirecturl : t -> string
745 val get_httpcode : t -> int
746 val get_responsecode : t -> int
747 val get_totaltime : t -> float
748 val get_namelookuptime : t -> float
749 val get_connecttime : t -> float
750 val get_pretransfertime : t -> float
751 val get_sizeupload : t -> float
752 val get_sizedownload : t -> float
753 val get_speeddownload : t -> float
754 val get_speedupload : t -> float
755 val get_headersize : t -> int
756 val get_requestsize : t -> int
757 val get_sslverifyresult : t -> int
758 val get_filetime : t -> float
759 val get_contentlengthdownload : t -> float
760 val get_contentlengthupload : t -> float
761 val get_starttransfertime : t -> float
762 val get_contenttype : t -> string
763 val get_redirecttime : t -> float
764 val get_redirectcount : t -> int
765 val get_private : t -> string
766 val get_httpconnectcode : t -> int
767 val get_httpauthavail : t -> curlAuth list
768 val get_proxyauthavail : t -> curlAuth list
769 val get_oserrno : t -> int
770 val get_numconnects : t -> int
771 val get_sslengines : t -> string list
772 val get_cookielist : t -> string list
773 val get_lastsocket : t -> int
774 val get_ftpentrypath : t -> string
775 val get_primaryip : t -> string
776 val get_localip : t -> string
777 (** @since 0.5.5 (libcurl 7.21.0) *)
778 val get_localport : t -> int
779 (** @since 0.5.5 (libcurl 7.21.0) *)
780 val get_conditionunmet : t -> bool
781 (** @since 0.6.1 (libcurl 7.19.4) *)
782 val get_certinfo : t -> string list list
784 (** {2 Object interface} *)
786 class handle :
787 object ('a)
788 val conn : t
789 method handle : t
790 method cleanup : unit
791 method duphandle : 'a
792 method perform : unit
794 method set_writefunction : (string -> int) -> unit
795 method set_readfunction : (int -> string) -> unit
796 method set_infilesize : int -> unit
797 method set_url : string -> unit
798 method set_proxy : string -> unit
799 method set_proxyport : int -> unit
800 method set_httpproxytunnel : bool -> unit
801 method set_verbose : bool -> unit
802 method set_header : bool -> unit
803 method set_noprogress : bool -> unit
804 method set_nosignal : bool -> unit
805 method set_nobody : bool -> unit
806 method set_failonerror : bool -> unit
807 method set_upload : bool -> unit
808 method set_post : bool -> unit
809 method set_ftplistonly : bool -> unit
810 method set_ftpappend : bool -> unit
811 method set_netrc : curlNETRCOption -> unit
812 method set_encoding : curlEncoding -> unit
813 method set_followlocation : bool -> unit
814 method set_transfertext : bool -> unit
815 method set_put : bool -> unit
816 method set_userpwd : string -> unit
817 method set_proxyuserpwd : string -> unit
818 method set_range : string -> unit
819 method set_errorbuffer : string ref -> unit
820 method set_timeout : int -> unit
821 method set_postfields : string -> unit
822 method set_postfieldsize : int -> unit
823 method set_referer : string -> unit
824 method set_useragent : string -> unit
825 method set_ftpport : string -> unit
826 method set_lowspeedlimit : int -> unit
827 method set_lowspeedtime : int -> unit
828 method set_resumefrom : int -> unit
829 method set_cookie : string -> unit
830 method set_httpheader : string list -> unit
831 method set_httppost : curlHTTPPost list -> unit
832 method set_sslcert : string -> unit
833 method set_sslcerttype : string -> unit
834 method set_sslcertpasswd : string -> unit
835 method set_sslkey : string -> unit
836 method set_sslkeytype : string -> unit
837 method set_sslkeypasswd : string -> unit
838 method set_sslengine : string -> unit
839 method set_sslenginedefault : bool -> unit
840 method set_certinfo : bool -> unit
841 method set_crlf : bool -> unit
842 method set_quote : string list -> unit
843 method set_postquote : string list -> unit
844 method set_headerfunction: (string -> int) -> unit
845 method set_cookiefile : string -> unit
846 method set_sslversion : curlSSLVersion -> unit
847 method set_timecondition : curlTimeCondition -> unit
848 method set_timevalue : int32 -> unit
849 method set_customrequest : string -> unit
850 method set_interface : string -> unit
851 method set_krb4level : curlKRB4Level -> unit
852 method set_progressfunction :
853 (float -> float -> float -> float -> bool) -> unit
854 method set_sslverifypeer : bool -> unit
855 method set_cainfo : string -> unit
856 method set_capath : string -> unit
857 method set_filetime : bool -> unit
858 method set_maxredirs : int -> unit
859 method set_maxconnects : int -> unit
860 method set_closepolicy : curlClosePolicy -> unit
861 method set_freshconnect : bool -> unit
862 method set_forbidreuse : bool -> unit
863 method set_randomfile : string -> unit
864 method set_egdsocket : string -> unit
865 method set_connecttimeout : int -> unit
866 method set_httpget : bool -> unit
867 method set_sslverifyhost : curlSSLVerifyHost -> unit
868 method set_cookiejar : string -> unit
869 method set_sslcipherlist : string -> unit
870 method set_httpversion : curlHTTPVersion -> unit
871 method set_ftpuseepsv : bool -> unit
872 method set_dnscachetimeout : int -> unit
873 method set_dnsuseglobalcache : bool -> unit
874 method set_debugfunction : (t -> curlDebugType -> string -> unit) -> unit
875 method set_private : string -> unit
876 method set_http200aliases : string list -> unit
877 method set_unrestrictedauth : bool -> unit
878 method set_ftpuseeprt : bool -> unit
879 method set_httpauth : curlAuth list -> unit
880 method set_ftpcreatemissingdirs : bool -> unit
881 method set_proxyauth : curlAuth list -> unit
882 method set_ftpresponsetimeout : int -> unit
883 method set_ipresolve : curlIPResolve -> unit
884 method set_maxfilesize : int32 -> unit
885 method set_infilesizelarge : int64 -> unit
886 method set_resumefromlarge : int64 -> unit
887 method set_maxfilesizelarge : int64 -> unit
888 method set_netrcfile : string -> unit
889 method set_ftpssl : curlFTPSSL -> unit
890 method set_postfieldsizelarge : int64 -> unit
891 method set_tcpnodelay : bool -> unit
892 method set_ftpsslauth : curlFTPSSLAuth -> unit
893 method set_ioctlfunction : (t -> curlIOCmd -> curlIOErr) -> unit
894 method set_ftpaccount : string -> unit
895 method set_cookielist : string -> unit
896 method set_ignorecontentlength : bool -> unit
897 method set_ftpskippasvip : bool -> unit
898 method set_ftpfilemethod : curlFTPMethod -> unit
899 method set_localport : int -> unit
900 method set_localportrange : int -> unit
901 method set_connectonly : bool -> unit
902 method set_maxsendspeedlarge : int64 -> unit
903 method set_maxrecvspeedlarge : int64 -> unit
904 method set_ftpalternativetouser : string -> unit
905 method set_sslsessionidcache : bool -> unit
906 method set_sshauthtypes : curlSSHAuthTypes list -> unit
907 method set_sshpublickeyfile : string -> unit
908 method set_sshprivatekeyfile : string -> unit
909 method set_ftpsslccc : curlFTPSSLCCC -> unit
910 method set_timeoutms : int -> unit
911 method set_connecttimeoutms : int -> unit
912 method set_httptransferdecoding : bool -> unit
913 method set_httpcontentdecoding : bool -> unit
914 method set_newfileperms : int -> unit
915 method set_newdirectoryperms : int -> unit
916 method set_post301 : bool -> unit
917 method set_sshhostpublickeymd5 : string -> unit
918 method set_copypostfields : string -> unit
919 method set_proxytransfermode : bool -> unit
920 method set_seekfunction : (int64 -> curlSeek -> curlSeekResult) -> unit
921 method set_autoreferer : bool -> unit
922 method set_opensocketfunction : (Unix.file_descr -> unit) -> unit
923 method set_proxytype : curlProxyType -> unit
924 method set_resolve : (string * int * string) list -> (string * int) list -> unit
925 method set_dns_servers : string list -> unit
926 method set_mimepost : curlMIMEPart list -> unit
927 method set_sshknownhosts : string -> unit
928 method set_sshkeyfunction : (curlKHMatch -> string -> curlKHStat) -> unit
930 method get_effectiveurl : string
931 method get_redirecturl : string
932 method get_httpcode : int
933 method get_responsecode : int
934 method get_totaltime : float
935 method get_namelookuptime : float
936 method get_connecttime : float
937 method get_pretransfertime : float
938 method get_sizeupload : float
939 method get_sizedownload : float
940 method get_speeddownload : float
941 method get_speedupload : float
942 method get_headersize : int
943 method get_requestsize : int
944 method get_sslverifyresult : int
945 method get_filetime : float
946 method get_contentlengthdownload : float
947 method get_contentlengthupload : float
948 method get_starttransfertime : float
949 method get_contenttype : string
950 method get_redirecttime : float
951 method get_redirectcount : int
952 method get_private : string
953 method get_httpconnectcode : int
954 method get_httpauthavail : curlAuth list
955 method get_proxyauthavail : curlAuth list
956 method get_oserrno : int
957 method get_numconnects : int
958 method get_sslengines : string list
959 method get_cookielist : string list
960 method get_lastsocket : int
961 method get_ftpentrypath : string
962 method get_primaryip : string
963 method get_localip : string
964 method get_localport : int
965 method get_conditionunmet : bool
966 method get_certinfo : string list list
969 (** {2 curl_multi API} *)
971 (** Curl multi stack. Functions may raise [Failure] on critical errors *)
972 module Multi : sig
974 (** type of Curl multi stack *)
975 type mt
977 type curlPipelining = PIPE_NOTHING | PIPE_HTTP1 | PIPE_MULTIPLEX
979 type curlMultiOption =
980 | CURLMOPT_PIPELINING of curlPipelining list
981 | CURLMOPT_MAXCONNECTS of int
982 | CURLMOPT_MAX_PIPELINE_LENGTH of int
983 | CURLMOPT_MAX_HOST_CONNECTIONS of int
985 (** exception raised on internal errors *)
986 exception Error of string
988 (** create new multi stack *)
989 val create : unit -> mt
991 (** add handle to multi stack *)
992 val add : mt -> t -> unit
994 (** remove handle from multi stack (effectively halting the transfer) *)
995 val remove : mt -> t -> unit
997 (** perform pending data transfers (if any) on all handles currently in multi stack
998 @return the number of handles that still transfer data *)
999 val perform : mt -> int
1001 (** wait till there are some active data transfers on multi stack
1002 @return whether [perform] should be called *)
1003 val wait : ?timeout_ms:int -> mt -> bool
1005 (** remove finished handle from the multi stack if any. The returned handle may be reused *)
1006 val remove_finished : mt -> (t * curlCode) option
1008 (** destroy multi handle (all transfers are stopped, but individual {!type: Curl.t} handles can be reused) *)
1009 val cleanup : mt -> unit
1011 (** events that should be reported for the socket *)
1012 type poll =
1013 | POLL_NONE (** none *)
1014 | POLL_IN (** available for reading *)
1015 | POLL_OUT (** available for writing *)
1016 | POLL_INOUT (** both *)
1017 | POLL_REMOVE (** socket not needed anymore *)
1019 (** socket status *)
1020 type fd_status =
1021 | EV_AUTO (** determine socket status automatically (with extra system call) *)
1022 | EV_IN (** socket has incoming data *)
1023 | EV_OUT (** socket is available for writing *)
1024 | EV_INOUT (** both *)
1026 (** set the function to receive notifications on what socket events
1027 are currently interesting for libcurl on the specified socket handle *)
1028 val set_socket_function : mt -> (Unix.file_descr -> poll -> unit) -> unit
1030 (** set the function to receive notification when libcurl internal timeout changes,
1031 timeout value is in milliseconds
1033 NB {!action_timeout} should be called when timeout occurs *)
1034 val set_timer_function : mt -> (int -> unit) -> unit
1036 (** perform pending data transfers (if any) on all handles currently in multi stack
1037 (not recommended, {!action} should be used instead)
1038 @return the number of handles that still transfer data
1039 @raise Error on errors
1041 val action_all : mt -> int
1043 (** inform libcurl that timeout occured
1044 @raise Error on errors
1046 val action_timeout : mt -> unit
1048 (** [action mt fd status] informs libcurl about event on the specified socket.
1049 [status] specifies socket status. Perform pending data transfers.
1050 @return the number of handles still active
1051 @raise Error on errors
1053 val action : mt -> Unix.file_descr -> fd_status -> int
1055 (** [timeout mt] polls multi handle for timeout (not recommended, use {!set_timer_function} instead).
1056 @return maximum allowed number of milliseconds to wait before calling libcurl to perform actions
1057 @raise Error on errors
1059 external timeout : mt -> int = "caml_curl_multi_timeout"
1061 (** @raise NotImplemented for not implemented option *)
1062 val setopt : mt -> curlMultiOption -> unit