Cohttp has been updated so I've corrected your code to use the latest version:
open Lwt;;
open Cohttp;;
(* a simple function to access the content of the response *)
let content = function
| Some (_, body) -> Cohttp_lwt_body.string_of_body body
| None -> assert false
(* launch both requests in parallel *)
let t = Lwt_list.map_p Cohttp_lwt_unix.Client.get
(List.map Uri.of_string
[ "http://google.com";
"http://yahoo.com" ])
(* maps the result through the content function *)
let t2 = t >>= Lwt_list.map_p content
(* launch the event loop *)
let v = Lwt_main.run t2
You can build with
ocamlbuild -use-ocamlfind -pkgs cohttp.lwt file.native
A couple of comments:
1) You should use the -use-ocamlfind
with ocamlbuild
to use opam (or any other installed ocaml libs)
2) To use cohttp with lwt you should use the cohttp.lwt
package. Adding lwt
as well is not strictly necessary.