From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id oBPKQHKu032375 for ; Sat, 25 Dec 2010 21:26:17 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvwAACbiFU3RVaE2kGdsb2JhbACDZJI0jhEIFQEBAQEJCQwHEQQgpQeJOzyCGIN8LohXAQEDBYEbgzZ0BIUhhWODHWk X-IronPort-AV: E=Sophos;i="4.60,229,1291590000"; d="scan'208";a="93187252" Received: from mail-fx0-f54.google.com ([209.85.161.54]) by mail1-smtp-roc.national.inria.fr with ESMTP; 25 Dec 2010 21:26:12 +0100 Received: by fxm16 with SMTP id 16so7925289fxm.27 for ; Sat, 25 Dec 2010 12:26:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=3uxvIC7M3zagvx0R6PjBSMQqh5V+ZSdcxOBHeOBhQ/k=; b=mnzY3vkfLD6dVI3tdhKgXltcT3DXN/8YJL23kI/dh29UA1nMBL/VdRr/7gv/t5CjAr k8K5RgX23Mu/cbMfg4bipzGkvvJkfokcmzqTZNv5ZZwxUssJJNHG4N+kLk9bThUtjUIP UxAju4dsPMsQiZSMgvcKkYduOo3ZeYflRRHHQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=H0w66zHYTAZMPuzlUNMj5t+T4bgfqjQbkIiasv0GdoNvBLHkGHCtXQ2CPvTCF7MVE3 R+PKQ7MMUJIKxyZZqkci96F8RX/FejpBGU/sZvtRAh4N5iXRE17MNRhqUsGF0EyZQrWF vY7xMRYgNtNV4gtLZMkr61NObEbZrTsR6201w= Received: by 10.223.103.5 with SMTP id i5mr4018735fao.31.1293308770654; Sat, 25 Dec 2010 12:26:10 -0800 (PST) Received: from [192.168.1.101] ([79.114.93.61]) by mx.google.com with ESMTPS id z1sm2598412fau.21.2010.12.25.12.26.09 (version=SSLv3 cipher=RC4-MD5); Sat, 25 Dec 2010 12:26:09 -0800 (PST) Message-ID: <4D165360.3010806@gmail.com> Date: Sat, 25 Dec 2010 22:26:08 +0200 From: =?UTF-8?B?VMO2csO2ayBFZHdpbg==?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101213 Icedove/3.1.7 MIME-Version: 1.0 To: caml-list@inria.fr References: <20101225004412.GA10078@siouxsie> <4D15A634.9000309@gmail.com> <20101225183021.GA9316@siouxsie> <20101225202101.GA12780@siouxsie> In-Reply-To: <20101225202101.GA12780@siouxsie> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] https... which lib? On 2010-12-25 22:21, oliver@first.in-berlin.de wrote: > On Sat, Dec 25, 2010 at 07:30:21PM +0100, oliver@first.in-berlin.de wrote: >> On Sat, Dec 25, 2010 at 10:07:16AM +0200, Török Edwin wrote: >>> On 2010-12-25 02:44, oliver@first.in-berlin.de wrote: >>>> Hi, >>>> >>>> AFAIK I can't use ocamlnet for https-files?! >>>> >>>> Which lib do I need for that? >>> >>> I used libcurl-ocaml for https recently. >> [...] >> >> http://curl.haxx.se/libcurl/ocaml/ >> >> Has a simple easy-to-start example... >> ... and https works out of the box. > [...] > > But documentation lacks.... > > The functions seem not to have the same names as the C-counterparts... > > What function do I need for not getting the webpage printed to stdout, > but into a string? Here's a snippet from my code: let new_curl_connection () = let buffer = Buffer.create 4096 and connection = new Curl.handle in let write_function str = Buffer.add_string buffer str; String.length str; in connection#set_writefunction write_function; connection#set_useragent Config.user_agent; connection#set_timeout Config.timeout; connection#set_followlocation true; connection#set_connecttimeout Config.connect_timeout; (* connection#set_verbose true;*) (connection, buffer);; let _ = let conn, buffer = new_curl_connection() in conn#set_url url; conn#perform; let http_code = conn#get_responsecode in if http_code < 400 then let result = Buffer.contents buffer; .... Also since you're using HTTPS you might want this: sslconn#set_sslverifypeer true; (* verify that certificate is valid for target host *) sslconn#set_sslverifyhost Curl.SSLVERIFYHOST_HOSTNAME; (* only accept our servers, optional *) sslconn#set_cainfo "ourserver_ca.pem";