[Pkg-ocaml-maint-commits] [ocurl] 07/23: Imported Upstream version 0.6.1
Stéphane Glondu
glondu at moszumanska.debian.org
Tue Feb 23 10:20:24 UTC 2016
This is an automated email from the git hooks/post-receive script.
glondu pushed a commit to branch master
in repository ocurl.
commit fe431f27e27273e6a20160502f46ecd6fd022286
Author: Stephane Glondu <steph at glondu.net>
Date: Tue Feb 23 10:39:37 2016 +0100
Imported Upstream version 0.6.1
---
CHANGES.txt | 9 ++++
README | 1 +
config.h.in | 4 ++
configure | 31 +++++++++----
configure.in | 4 +-
curl-helper.c | 109 +++++++++++++++++++++++++++++-----------------
curl.ml | 20 ++++++++-
curl.mli | 39 ++++++++++++-----
examples/Makefile.in | 4 +-
examples/Makefile.windows | 2 +-
examples/test_cb_exn.ml | 25 +++++++++++
11 files changed, 181 insertions(+), 67 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 66e2a98..58f31ea 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,12 @@
+0.6.1 - 11 Feb 2014
+
+ * fix type of set_seekfunction
+ * fix handling of exceptions from callbacks (break the transfer)
+ + CURLINFO_CONDITION_UNMET TIMECOND_NONE TIMECOND_LASTMOD
+ * fix build on windows
+ * expose Curl.t underlying Curl.handle object
+ * implement Curl.handle#get_redirecturl
+
0.6.0 - 29 Aug 2013
* introduce bindings to asynchronous multi interface
diff --git a/README b/README
index 402487f..a8231ab 100644
--- a/README
+++ b/README
@@ -39,6 +39,7 @@ Making release
* Update CHANGES.txt
* Update version in configure.in
+* autoreconf
* make release
----
diff --git a/config.h.in b/config.h.in
index b52e628..79e8d39 100644
--- a/config.h.in
+++ b/config.h.in
@@ -320,6 +320,10 @@
you don't. */
#undef HAVE_DECL_CURLE_WRITE_ERROR
+/* Define to 1 if you have the declaration of `CURLINFO_CONDITION_UNMET', and
+ to 0 if you don't. */
+#undef HAVE_DECL_CURLINFO_CONDITION_UNMET
+
/* Define to 1 if you have the declaration of `CURLINFO_CONNECT_TIME', and to
0 if you don't. */
#undef HAVE_DECL_CURLINFO_CONNECT_TIME
diff --git a/configure b/configure
index db11358..c13a25a 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for ocurl 0.6.0.
+# Generated by GNU Autoconf 2.69 for ocurl 0.6.1.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -576,8 +576,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ocurl'
PACKAGE_TARNAME='ocurl'
-PACKAGE_VERSION='0.6.0'
-PACKAGE_STRING='ocurl 0.6.0'
+PACKAGE_VERSION='0.6.1'
+PACKAGE_STRING='ocurl 0.6.1'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1201,7 +1201,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures ocurl 0.6.0 to adapt to many kinds of systems.
+\`configure' configures ocurl 0.6.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1262,7 +1262,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of ocurl 0.6.0:";;
+ short | recursive ) echo "Configuration of ocurl 0.6.1:";;
esac
cat <<\_ACEOF
@@ -1341,7 +1341,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-ocurl configure 0.6.0
+ocurl configure 0.6.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1442,7 +1442,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by ocurl $as_me 0.6.0, which was
+It was created by ocurl $as_me 0.6.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -6249,6 +6249,19 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_CURLINFO_LOCAL_PORT $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "CURLINFO_CONDITION_UNMET" "ac_cv_have_decl_CURLINFO_CONDITION_UNMET" "
+#include \"curl/curl.h\"
+
+"
+if test "x$ac_cv_have_decl_CURLINFO_CONDITION_UNMET" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_CURLINFO_CONDITION_UNMET $ac_have_decl
+_ACEOF
ac_fn_c_check_decl "$LINENO" "CURLE_UNSUPPORTED_PROTOCOL" "ac_cv_have_decl_CURLE_UNSUPPORTED_PROTOCOL" "
#include \"curl/curl.h\"
@@ -7828,7 +7841,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by ocurl $as_me 0.6.0, which was
+This file was extended by ocurl $as_me 0.6.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7890,7 +7903,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-ocurl config.status 0.6.0
+ocurl config.status 0.6.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.in b/configure.in
index d582e75..b0ee3b9 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@ dnl
dnl ocurl autoconf input
dnl
-AC_INIT(ocurl,0.6.0)
+AC_INIT(ocurl,0.6.1)
AC_PROG_CC()
@@ -91,7 +91,7 @@ CURLINFO_PRIVATE, CURLINFO_HTTP_CONNECTCODE, CURLINFO_HTTPAUTH_AVAIL,
CURLINFO_PROXYAUTH_AVAIL, CURLINFO_OS_ERRNO, CURLINFO_NUM_CONNECTS,
CURLINFO_SSL_ENGINES, CURLINFO_COOKIELIST, CURLINFO_LASTSOCKET,
CURLINFO_FTP_ENTRY_PATH, CURLINFO_REDIRECT_URL, CURLINFO_PRIMARY_IP,
-CURLINFO_LOCAL_IP, CURLINFO_LOCAL_PORT,
+CURLINFO_LOCAL_IP, CURLINFO_LOCAL_PORT, CURLINFO_CONDITION_UNMET,
CURLE_UNSUPPORTED_PROTOCOL, CURLE_FAILED_INIT, CURLE_URL_MALFORMAT,
CURLE_URL_MALFORMAT_USER, CURLE_COULDNT_RESOLVE_PROXY,
diff --git a/curl-helper.c b/curl-helper.c
index 78e8494..6e8a39f 100644
--- a/curl-helper.c
+++ b/curl-helper.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <unistd.h>
#include <curl/curl.h>
#include <caml/alloc.h>
@@ -24,12 +25,6 @@
#pragma message("No config file given.")
#endif
-#if defined(_MSC_VER)
-#ifdef interface
-#undef interface
-#endif
-#endif
-
void leave_blocking_section(void);
void enter_blocking_section(void);
@@ -156,7 +151,7 @@ struct Connection
struct curl_slist *postQuote;
char *cookieFile;
char *customRequest;
- char *interface;
+ char *interface_; /* `interface` gives problems on windows */
char *caInfo;
char *caPath;
char *randomFile;
@@ -1219,7 +1214,7 @@ static Connection *newConnection(void)
connection->postQuote = NULL;
connection->cookieFile = NULL;
connection->customRequest = NULL;
- connection->interface = NULL;
+ connection->interface_ = NULL;
connection->caInfo = NULL;
connection->caPath = NULL;
connection->randomFile = NULL;
@@ -1324,7 +1319,7 @@ static Connection *duplicateConnection(Connection *original)
connection->postQuote = NULL;
connection->cookieFile = NULL;
connection->customRequest = NULL;
- connection->interface = NULL;
+ connection->interface_ = NULL;
connection->caInfo = NULL;
connection->caPath = NULL;
connection->randomFile = NULL;
@@ -1517,7 +1512,7 @@ static void removeConnection(Connection *connection)
free_curl_slist(connection->postQuote);
free_if(connection->cookieFile);
free_if(connection->customRequest);
- free_if(connection->interface);
+ free_if(connection->interface_);
free_if(connection->caInfo);
free_if(connection->caPath);
free_if(connection->randomFile);
@@ -1603,9 +1598,9 @@ static size_t writeFunction_nolock(char *ptr, size_t size, size_t nmemb, void *d
for (i = 0; i < size*nmemb; i++)
Byte(str, i) = ptr[i];
- result = callback(Field(conn->ocamlValues, OcamlWriteCallback), str);
+ result = callback_exn(Field(conn->ocamlValues, OcamlWriteCallback), str);
- CAMLreturnT(size_t, Int_val(result));
+ CAMLreturnT(size_t, Is_exception_result(result) ? 0 : Int_val(result));
}
WRAP_DATA_CALLBACK(writeFunction)
@@ -1619,9 +1614,14 @@ static size_t readFunction_nolock(void *ptr, size_t size, size_t nmemb, void *da
checkConnection(conn);
- result = callback(Field(conn->ocamlValues, OcamlReadCallback),
+ result = callback_exn(Field(conn->ocamlValues, OcamlReadCallback),
Val_int(size*nmemb));
+ if (Is_exception_result(result))
+ {
+ CAMLreturnT(size_t,CURL_READFUNC_ABORT);
+ }
+
length = string_length(result);
if (length >= size*nmemb)
@@ -1648,9 +1648,9 @@ static size_t headerFunction_nolock(char *ptr, size_t size, size_t nmemb, void *
for (i = 0; i < size*nmemb; i++)
Byte(str, i) = ptr[i];
- result = callback(Field(conn->ocamlValues, OcamlHeaderCallback), str);
+ result = callback_exn(Field(conn->ocamlValues, OcamlHeaderCallback), str);
- CAMLreturnT(size_t, Int_val(result));
+ CAMLreturnT(size_t, Is_exception_result(result) ? 0 : Int_val(result));
}
WRAP_DATA_CALLBACK(headerFunction)
@@ -1673,10 +1673,10 @@ static int progressFunction_nolock(void *data,
callbackData[2] = copy_double(ulTotal);
callbackData[3] = copy_double(ulNow);
- result = callbackN(Field(conn->ocamlValues, OcamlProgressCallback),
+ result = callbackN_exn(Field(conn->ocamlValues, OcamlProgressCallback),
4, callbackData);
- CAMLreturnT(int, Bool_val(result));
+ CAMLreturnT(int, Is_exception_result(result) ? 1 : Bool_val(result));
}
static int progressFunction(void *data,
@@ -1713,7 +1713,7 @@ static int debugFunction_nolock(CURL *debugConnection,
for (i = 0; i < bufferLength; i++)
Byte(camlMessage, i) = buffer[i];
- callback3(Field(conn->ocamlValues, OcamlDebugCallback),
+ callback3_exn(Field(conn->ocamlValues, OcamlDebugCallback),
camlDebugConnection,
camlInfoType,
camlMessage);
@@ -1756,10 +1756,15 @@ static curlioerr ioctlFunction_nolock(CURL *ioctl,
camlConnection = caml_alloc(1, Abstract_tag);
Field(camlConnection, 0) = (value)conn;
- camlResult = callback2(Field(conn->ocamlValues, OcamlIOCTLCallback),
+ camlResult = callback2_exn(Field(conn->ocamlValues, OcamlIOCTLCallback),
camlConnection,
camlCmd);
+ if (Is_exception_result(camlResult))
+ {
+ result = CURLIOE_FAILRESTART;
+ }
+ else
switch (Long_val(camlResult))
{
case 0: /* CURLIOE_OK */
@@ -1801,7 +1806,6 @@ static int seekFunction_nolock(void *data,
CAMLparam0();
CAMLlocal3(camlResult, camlOffset, camlOrigin);
Connection *conn = (Connection *)data;
- int result = 0;
camlOffset = copy_int64(offset);
@@ -1812,14 +1816,24 @@ static int seekFunction_nolock(void *data,
else if (origin == SEEK_END)
camlOrigin = Val_long(2);
else
- camlOrigin = Val_long(0);
+ failwith("Invalid seek code");
- camlResult = callback2(Field(conn->ocamlValues,
+ camlResult = callback2_exn(Field(conn->ocamlValues,
OcamlSeekFunctionCallback),
camlOffset,
camlOrigin);
- result = Int_val(camlResult);
+ int result;
+ if (Is_exception_result(camlResult))
+ result = CURL_SEEKFUNC_FAIL;
+ else
+ switch (Int_val(camlResult))
+ {
+ case 0: result = CURL_SEEKFUNC_OK; break;
+ case 1: result = CURL_SEEKFUNC_FAIL; break;
+ case 2: result = CURL_SEEKFUNC_CANTSEEK; break;
+ default: failwith("Invalid seek result");
+ }
CAMLreturnT(int, result);
}
@@ -1843,6 +1857,7 @@ static int openSocketFunction_nolock(void *data,
struct curl_sockaddr *addr)
{
CAMLparam0();
+ CAMLlocal1(result);
Connection *conn = (Connection *)data;
int sock = -1;
(void)purpose; /* not used */
@@ -1852,10 +1867,15 @@ static int openSocketFunction_nolock(void *data,
if (-1 != sock)
{
/* FIXME windows */
- callback(Field(conn->ocamlValues, OcamlOpenSocketFunctionCallback), Val_int(sock));
+ result = callback_exn(Field(conn->ocamlValues, OcamlOpenSocketFunctionCallback), Val_int(sock));
+ if (Is_exception_result(result))
+ {
+ close(sock);
+ sock = -1;
+ }
}
- CAMLreturnT(int, sock);
+ CAMLreturnT(int, (sock == -1) ? CURL_SOCKET_BAD : sock);
}
static int openSocketFunction(void *data,
@@ -3385,26 +3405,21 @@ static void handleTimeCondition(Connection *conn, value option)
{
CAMLparam1(option);
CURLcode result = CURLE_OK;
+ int timecond = CURL_TIMECOND_NONE;
switch (Long_val(option))
{
- case 0: /* TIMECOND_IFMODSINCE */
- result = curl_easy_setopt(conn->connection,
- CURLOPT_TIMECONDITION,
- CURL_TIMECOND_IFMODSINCE);
- break;
-
- case 1: /* TIMECOND_IFUNMODSINCE */
- result = curl_easy_setopt(conn->connection,
- CURLOPT_TIMECONDITION,
- CURL_TIMECOND_IFUNMODSINCE);
- break;
-
+ case 0: timecond = CURL_TIMECOND_NONE; break;
+ case 1: timecond = CURL_TIMECOND_IFMODSINCE; break;
+ case 2: timecond = CURL_TIMECOND_IFUNMODSINCE; break;
+ case 3: timecond = CURL_TIMECOND_LASTMOD; break;
default:
failwith("Invalid TIMECOND Option");
break;
}
+ result = curl_easy_setopt(conn->connection, CURLOPT_TIMECONDITION, timecond);
+
if (result != CURLE_OK)
raiseError(conn, result);
@@ -3455,14 +3470,14 @@ static void handleInterface(Connection *conn, value option)
Store_field(conn->ocamlValues, OcamlInterface, option);
- if (conn->interface != NULL)
- free(conn->interface);
+ if (conn->interface_ != NULL)
+ free(conn->interface_);
- conn->interface = strdup(String_val(option));
+ conn->interface_ = strdup(String_val(option));
result = curl_easy_setopt(conn->connection,
CURLOPT_INTERFACE,
- conn->interface);
+ conn->interface_);
if (result != CURLE_OK)
raiseError(conn, result);
@@ -6001,6 +6016,18 @@ CAMLprim value helper_curl_easy_getinfo(value conn, value option)
#pragma message("libcurl does not provide CURLINFO_LOCAL_PORT")
#endif
+#if HAVE_DECL_CURLINFO_CONDITION_UNMET
+ case 35: /* CURLINFO_CONDITION_UNMET */
+ resultType = LongValue;
+
+ curlResult = curl_easy_getinfo(connection->connection,
+ CURLINFO_CONDITION_UNMET,
+ &longValue);
+ break;
+#else
+#pragma message("libcurl does not provide CURLINFO_CONDITION_UNMET")
+#endif
+
default:
failwith("Invalid CURLINFO Option");
break;
diff --git a/curl.ml b/curl.ml
index 25226fb..54c3451 100644
--- a/curl.ml
+++ b/curl.ml
@@ -114,7 +114,7 @@ type curlHTTPPost =
| CURLFORM_FILE of string * string * curlContentType
| CURLFORM_BUFFER of string * string * string * curlContentType
-(*
+(*
type curlHTTPPost =
| CURLFORM_COPYNAME of string
| CURLFORM_PTRNAME of string
@@ -128,8 +128,10 @@ type curlHTTPPost =
*)
type curlTimeCondition =
+ | TIMECOND_NONE
| TIMECOND_IFMODSINCE
| TIMECOND_IFUNMODSINCE
+ | TIMECOND_LASTMOD
type curlKRB4Level =
| KRB4_NONE
@@ -193,6 +195,11 @@ type curlIOErr =
| IOE_UNKNOWNCMD
| IOE_FAILRESTART
+type curlSeekResult =
+ | SEEKFUNC_OK
+ | SEEKFUNC_FAIL
+ | SEEKFUNC_CANTSEEK
+
type curlFTPMethod =
| FTPMETHOD_DEFAULT
| FTPMETHOD_MULTICWD
@@ -380,7 +387,7 @@ type curlOption =
| CURLOPT_SSHHOSTPUBLICKEYMD5 of string
| CURLOPT_COPYPOSTFIELDS of string
| CURLOPT_PROXYTRANSFERMODE of bool
- | CURLOPT_SEEKFUNCTION of (int64 -> curlSeek -> int)
+ | CURLOPT_SEEKFUNCTION of (int64 -> curlSeek -> curlSeekResult)
| CURLOPT_AUTOREFERER of bool
| CURLOPT_OPENSOCKETFUNCTION of (Unix.file_descr -> unit)
| CURLOPT_PROXYTYPE of curlProxyType
@@ -431,6 +438,7 @@ type curlInfo =
| CURLINFO_PRIMARY_IP
| CURLINFO_LOCAL_IP
| CURLINFO_LOCAL_PORT
+ | CURLINFO_CONDITION_UNMET
type curlInfoResult =
| CURLINFO_String of string
@@ -1092,6 +1100,11 @@ let get_localport conn =
| CURLINFO_Long n -> n
| _ -> 0
+let get_conditionunmet conn =
+ match (getinfo conn CURLINFO_CONDITION_UNMET) with
+ | CURLINFO_Long n -> n <> 0
+ | _ -> assert false
+
let () =
Callback.register_exception "CurlException"
(CurlException (CURLE_OK, 0, ""))
@@ -1099,6 +1112,7 @@ let () =
class handle =
object
val conn = init ()
+ method handle = conn
method duphandle = {< conn = duphandle conn >}
method perform = perform conn
method cleanup = cleanup conn
@@ -1235,6 +1249,7 @@ class handle =
method set_proxytype t = set_proxytype conn t
method get_effectiveurl = get_effectiveurl conn
+ method get_redirecturl = get_redirecturl conn
method get_responsecode = get_responsecode conn
method get_httpcode = get_responsecode conn
method get_totaltime = get_totaltime conn
@@ -1268,6 +1283,7 @@ class handle =
method get_primaryip = get_primaryip conn
method get_localip = get_localip conn
method get_localport = get_localport conn
+ method get_conditionunmet = get_conditionunmet conn
end
module Multi = struct
diff --git a/curl.mli b/curl.mli
index f5d7314..f5b1a9a 100644
--- a/curl.mli
+++ b/curl.mli
@@ -130,9 +130,11 @@ type curlHTTPPost =
*)
type curlTimeCondition =
+ | TIMECOND_NONE (** since 0.6.1 *)
| TIMECOND_IFMODSINCE
| TIMECOND_IFUNMODSINCE
-
+ | TIMECOND_LASTMOD (** since 0.6.1 *)
+
type curlKRB4Level =
| KRB4_NONE
| KRB4_CLEAR
@@ -195,6 +197,11 @@ type curlIOErr =
| IOE_UNKNOWNCMD
| IOE_FAILRESTART
+type curlSeekResult =
+ | SEEKFUNC_OK
+ | SEEKFUNC_FAIL
+ | SEEKFUNC_CANTSEEK
+
type curlFTPMethod =
| FTPMETHOD_DEFAULT
| FTPMETHOD_MULTICWD
@@ -220,11 +227,11 @@ type curlSeek =
type curlProxyType =
| CURLPROXY_HTTP
- | CURLPROXY_HTTP_1_0 (** added in 7.19.4 *)
- | CURLPROXY_SOCKS4 (** added in 7.15.2 *)
+ | CURLPROXY_HTTP_1_0 (** since libcurl 7.19.4 *)
+ | CURLPROXY_SOCKS4 (** since libcurl 7.15.2 *)
| CURLPROXY_SOCKS5
- | CURLPROXY_SOCKS4A (** added in 7.18.0 *)
- | CURLPROXY_SOCKS5_HOSTNAME (** added in 7.18.0 *)
+ | CURLPROXY_SOCKS4A (** since libcurl 7.18.0 *)
+ | CURLPROXY_SOCKS5_HOSTNAME (** since libcurl 7.18.0 *)
(** Protocols to enable (via CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS) *)
type curlProto =
@@ -382,7 +389,7 @@ type curlOption =
| CURLOPT_SSHHOSTPUBLICKEYMD5 of string
| CURLOPT_COPYPOSTFIELDS of string
| CURLOPT_PROXYTRANSFERMODE of bool
- | CURLOPT_SEEKFUNCTION of (int64 -> curlSeek -> int)
+ | CURLOPT_SEEKFUNCTION of (int64 -> curlSeek -> curlSeekResult)
| CURLOPT_AUTOREFERER of bool
| CURLOPT_OPENSOCKETFUNCTION of (Unix.file_descr -> unit)
| CURLOPT_PROXYTYPE of curlProxyType
@@ -431,8 +438,9 @@ type curlInfo =
| CURLINFO_FTP_ENTRY_PATH
| CURLINFO_REDIRECT_URL
| CURLINFO_PRIMARY_IP
- | CURLINFO_LOCAL_IP (** @since 7.21.0 *)
- | CURLINFO_LOCAL_PORT (** @since 7.21.0 *)
+ | CURLINFO_LOCAL_IP
+ | CURLINFO_LOCAL_PORT
+ | CURLINFO_CONDITION_UNMET
type curlInfoResult =
| CURLINFO_String of string
@@ -476,6 +484,10 @@ val errno : curlCode -> int
val version_info : unit -> version_info
val pause : t -> pauseOption list -> unit
+(** NB
+ All callback functions shouldn't raise exceptions.
+ Any exception raised in callback function will be silently caught and discared,
+ and transfer will be aborted. *)
val set_writefunction : t -> (string -> int) -> unit
val set_readfunction : t -> (int -> string) -> unit
val set_infilesize : t -> int -> unit
@@ -600,7 +612,7 @@ val set_post301 : t -> bool -> unit
val set_sshhostpublickeymd5 : t -> string -> unit
val set_copypostfields : t -> string -> unit
val set_proxytransfermode : t -> bool -> unit
-val set_seekfunction : t -> (int64 -> curlSeek -> int) -> unit
+val set_seekfunction : t -> (int64 -> curlSeek -> curlSeekResult) -> unit
val set_autoreferer : t -> bool -> unit
val set_opensocketfunction : t -> (Unix.file_descr -> unit) -> unit
val set_proxytype : t -> curlProxyType -> unit
@@ -649,11 +661,16 @@ val get_lastsocket : t -> int
val get_ftpentrypath : t -> string
val get_primaryip : t -> string
val get_localip : t -> string
+(** @since 0.5.5 (libcurl 7.21.0) *)
val get_localport : t -> int
+(** @since 0.5.5 (libcurl 7.21.0) *)
+val get_conditionunmet : t -> bool
+(** @since 0.6.1 (libcurl 7.19.4) *)
class handle :
object ('a)
val conn : t
+ method handle : t
method cleanup : unit
method duphandle : 'a
method perform : unit
@@ -783,7 +800,7 @@ class handle :
method set_sshhostpublickeymd5 : string -> unit
method set_copypostfields : string -> unit
method set_proxytransfermode : bool -> unit
- method set_seekfunction : (int64 -> curlSeek -> int) -> unit
+ method set_seekfunction : (int64 -> curlSeek -> curlSeekResult) -> unit
method set_autoreferer : bool -> unit
method set_opensocketfunction : (Unix.file_descr -> unit) -> unit
method set_proxytype : curlProxyType -> unit
@@ -791,6 +808,7 @@ class handle :
method set_dns_servers : string list -> unit
method get_effectiveurl : string
+ method get_redirecturl : string
method get_httpcode : int
method get_responsecode : int
method get_totaltime : float
@@ -824,6 +842,7 @@ class handle :
method get_primaryip : string
method get_localip : string
method get_localport : int
+ method get_conditionunmet : bool
end
(** Curl multi stack. Functions may raise [Failure] on critical errors *)
diff --git a/examples/Makefile.in b/examples/Makefile.in
index 2c30d75..71b2eea 100644
--- a/examples/Makefile.in
+++ b/examples/Makefile.in
@@ -17,9 +17,9 @@ OCURLOPTLIB = curl.cmxa unix.cmxa threads.cmxa
ifeq (@OCAMLBEST@,opt)
TARGETS = ocurl ocurl.opt oput oput.opt ominimal ominimal.opt ossl ossl.opt \
- ocurl_test_threads ocurl_test_threads.opt opar opar.opt
+ ocurl_test_threads ocurl_test_threads.opt opar opar.opt test_cb_exn.opt
else
-TARGETS = ocurl oput ominimal ossl ocurl_test_threads opar
+TARGETS = ocurl oput ominimal ossl ocurl_test_threads opar test_cb_exn
endif
all: $(TARGETS)
diff --git a/examples/Makefile.windows b/examples/Makefile.windows
index e188687..25f34b6 100644
--- a/examples/Makefile.windows
+++ b/examples/Makefile.windows
@@ -16,7 +16,7 @@ LFLAGS = -I ..
OCURLLIB = -dllpath .. curl.cma
OCURLOPTLIB = curl.cmxa
-TARGETS = ocurl.exe ocurl.opt.exe oput.exe oput.opt.exe ominimal.exe ominimal.opt.exe ossl.exe ossl.opt.exe omulti.exe omulti.opt.exe
+TARGETS = ocurl.exe ocurl.opt.exe oput.exe oput.opt.exe ominimal.exe ominimal.opt.exe ossl.exe ossl.opt.exe omulti.exe omulti.opt.exe test_cb_exn.exe
all:
@$(MAKE) -f Makefile.windows depend
diff --git a/examples/test_cb_exn.ml b/examples/test_cb_exn.ml
new file mode 100644
index 0000000..2656a80
--- /dev/null
+++ b/examples/test_cb_exn.ml
@@ -0,0 +1,25 @@
+(* Copyright (c) 2013, Thomas Leonard, <talex5 at gmail.com> *)
+
+open Printf
+
+exception Abort
+
+let () =
+ let open Curl in
+ let connection = init () in
+ let error_buffer = ref "" in
+
+ set_writefunction connection (fun _ -> raise Abort);
+ set_url connection "http://google.com";
+ set_errorbuffer connection error_buffer;
+
+ let run () =
+ try
+ perform connection;
+ with
+ | CurlException (CURLE_WRITE_ERROR,_,_) -> printf "ok\n%!"
+ | exn -> printf "E: wrong error: %s : %s\n%!" (Printexc.to_string exn) !error_buffer
+ in
+ run ();
+ run ();
+ cleanup connection
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/ocurl.git
More information about the Pkg-ocaml-maint-commits
mailing list