Added wrappers around some common libraries.
[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.1 2003-10-12 17:33:15 rich Exp $
4  *)
5
6 open Perl
7
8 open Pl_HTTP_Message
9 open Pl_URI
10
11 class http_request sv =
12
13 object (self)
14   inherit http_message sv
15
16   method sv = sv
17
18   method method_ =
19     string_of_sv (call_method sv "method" [])
20   method set_method meth =
21     call_method_void sv "method" [sv_of_string meth]
22   method as_string =
23     string_of_sv (call_method sv "as_string" [])
24
25 end
26
27 let new_ meth ?uri_obj ?uri (* ?header ?content *) () =
28   let sv =
29     match uri_obj, uri with
30         None, None ->
31           failwith ("Pl_HTTP_Request.new_ must be called with either a "^
32                     "~uri_obj (URI object) or ~uri (string) parameter.")
33       | Some (uri_obj : uri), None ->
34           call_class_method "HTTP::Request" "new" [sv_of_string meth;
35                                                    uri_obj#sv]
36       | _, Some uri ->
37           call_class_method "HTTP::Request" "new" [sv_of_string meth;
38                                                    sv_of_string uri]
39   in
40   new http_request sv