Skip to content
This repository
Newer
Older
100644 136 lines (112 sloc) 3.28 kb
fccc6851 » MLstate
2011-06-21 Initial open-source release
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (**
20 Http dialog component
21 @author Cedric Soulas
22 *)
23
24 (**
25 This module reply to an http client request via the provided dialog function.
26 This module is a RuntimeSig.COMPONENT.
27 *)
28
29 (** {6 Types and functions to comply with RuntimeSig.COMPONENT} *)
30
31 type t
32 (** Internal type *)
33
34 type port = {
35 set_dialog : t -> unit
36 }
37 (**
38 Port to be used by http server via the runtime layer.
39 See [RuntimeType.Ports.t].
40 *)
41
42
43 type dialog = Scheduler.t -> HttpServerTypes.web_info -> unit
44
45 type options = {
46 opt_allowed : Unix.inet_addr -> bool;
47 dialog_name : string;
48 dialog : unit -> dialog;
49 opt_url_prefix : string;
50 }
51 (**
52 Type to define the http dialog.
53 See [make].
54 *)
55 val name : string
56 val version : string
57
58 val default_options : options
59 (**
60 Default options of the http dialog.
61 [options_with_dialog] can be used to define a dialog.
62 Default options are:
63 opt_allowed always return true,
64 dialog_name is "default",
65 dialog is null,
66 opt_url_prefix is empty.
67 *)
68
69 val spec_args : string -> (options ServerArg.arg_parser) list
70 (**
71 Return the command line parser specification.
72 *)
73
74 val make : string -> options -> Scheduler.t -> t
75 (**
76 [make name options sched] make a fresh [t] from provided name and options.
77 The name is used to prefix the command line options.
78 *)
79
80 val run :
81 t ->
82 Scheduler.t ->
83 t
84 (**
85 Run the http dialog.
86 It forces the evaluation of the provided dialog function.
87 *)
88
89 val get_ports :
90 t ->
91 Scheduler.t ->
92 (string * [> ]) list
93 (**
94 This function return an empty port declaration (the http dialog accepts no port),
95 to comply with [RuntimeSig.COMPONENT].
96 *)
97
98 val get_description :
99 t ->
100 Scheduler.t ->
101 [> `HttpDialog of t]
102 (**
103 Return an http dialog description, to comply with [RuntimeSig.COMPONENT].
104 *)
105
106 val close :
107 t ->
108 Scheduler.t ->
109 unit
110 (**
111 This function does nothing, but it complies with [RuntimeSig.COMPONENT].
112 *)
113
114 (** {6 Misc.} *)
115
116 val options_with_dialog : (unit -> dialog) -> options
117 (**
118 Return a [default_options] but with the provided dialog.
119 *)
120
121 val body : t -> Scheduler.t -> HttpServerTypes.web_info -> unit
122 (**
123 Reply to an http client request via the provided [HttpServerTypes.web_info].
124 *)
125
126 val content : t -> (string -> int -> int -> unit)
127 (**
128 Deprecated.
129 It was used for upload progress information.
130 *)
131
132 val is_allowed : t -> Scheduler.connection_info -> bool
133 (**
134 Deprecated.
135 It was used to check if [Scheduler.connection_info] is allowed to receive a response.
136 *)
Something went wrong with that request. Please try again.