Wrappers now automatically 'use' modules.
[perl4caml.git] / wrappers / pl_HTTP_Request.ml
1 (* Wrapper around Perl HTTP::Request class.
2  * Copyright (C) 2003 Merjis Ltd.
3  * $Id: pl_HTTP_Request.ml,v 1.2 2003-10-15 16:51:12 rich Exp $
4  *)
5
6 open Perl
7
8 open Pl_HTTP_Message
9 open Pl_URI
10
11 let _ = eval "use HTTP::Request"
12
13 class http_request sv =
14
15 object (self)
16   inherit http_message sv
17
18   method sv = sv
19
20   method method_ =
21     string_of_sv (call_method sv "method" [])
22   method set_method meth =
23     call_method_void sv "method" [sv_of_string meth]
24   method as_string =
25     string_of_sv (call_method sv "as_string" [])
26
27 end
28
29 let new_ meth ?uri_obj ?uri (* ?header ?content *) () =
30   let sv =
31     match uri_obj, uri with
32         None, None ->
33           failwith ("Pl_HTTP_Request.new_ must be called with either a "^
34                     "~uri_obj (URI object) or ~uri (string) parameter.")
35       | Some (uri_obj : uri), None ->
36           call_class_method "HTTP::Request" "new" [sv_of_string meth;
37                                                    uri_obj#sv]
38       | _, Some uri ->
39           call_class_method "HTTP::Request" "new" [sv_of_string meth;
40                                                    sv_of_string uri]
41   in
42   new http_request sv