1 (* Wrapper around Perl LWP::UserAgent class.
2 * Copyright (C) 2003 Merjis Ltd.
3 * $Id: pl_LWP_UserAgent.ml,v 1.1 2003-10-12 17:33:15 rich Exp $
11 class lwp_useragent sv =
15 method simple_request (request : http_request) =
16 let sv = call_method sv "simple_request" [request#sv] in
18 method request (request : http_request) =
19 let sv = call_method sv "simple_request" [request#sv] in
22 string_of_sv (call_method sv "agent" [])
24 call_method_void sv "agent" [sv_of_string v]
26 string_of_sv (call_method sv "from" [])
28 call_method_void sv "from" [sv_of_string v]
30 int_of_sv (call_method sv "timeout" [])
31 method set_timeout v =
32 call_method_void sv "timeout" [sv_of_int v]
34 bool_of_sv (call_method sv "parse_head" [])
35 method set_parse_head v =
36 call_method_void sv "parse_head" [sv_of_bool v]
38 int_of_sv (call_method sv "max_size" [])
39 method set_max_size v =
40 call_method_void sv "max_size" [sv_of_int v]
42 call_method_void sv "env_proxy" []
46 (* Note that "new" is a reserved word, so I've appended an _ character. *)
47 let new_ ?agent ?from ?timeout ?use_eval ?parse_head ?max_size
48 ?env_proxy ?keep_alive () =
50 let may f = function None -> () | Some v -> f v in
52 args := sv_of_string "agent" :: sv_of_string v :: !args) agent;
54 args := sv_of_string "from" :: sv_of_string v :: !args) from;
56 args := sv_of_string "timeout" :: sv_of_int v :: !args) timeout;
58 args := sv_of_string "use_eval" :: sv_of_bool v :: !args) use_eval;
60 args := sv_of_string "parse_head" :: sv_of_bool v :: !args)parse_head;
62 args := sv_of_string "max_size" :: sv_of_int v :: !args) max_size;
64 args := sv_of_string "env_proxy" :: sv_of_bool v :: !args) env_proxy;
66 args := sv_of_string "keep_alive" :: sv_of_int v :: !args) keep_alive;
67 let sv = call_class_method "LWP::UserAgent" "new" !args in