From: "Török Edwin" <edwintorok@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] https... which lib?
Date: Sat, 25 Dec 2010 22:26:08 +0200 [thread overview]
Message-ID: <4D165360.3010806@gmail.com> (raw)
In-Reply-To: <20101225202101.GA12780@siouxsie>
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";
next prev parent reply other threads:[~2010-12-25 20:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-25 0:44 oliver
2010-12-25 8:07 ` Török Edwin
2010-12-25 16:45 ` oliver
2010-12-25 18:30 ` oliver
2010-12-25 20:21 ` oliver
2010-12-25 20:26 ` Török Edwin [this message]
2010-12-25 20:46 ` oliver
2010-12-25 23:10 ` oliver
2010-12-26 9:07 ` Török Edwin
2010-12-25 23:38 ` oliver
2010-12-25 23:58 ` oliver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D165360.3010806@gmail.com \
--to=edwintorok@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox