Skip to content
This repository
tag: v670
Fetching contributors…

Cannot retrieve contributors at this time

file 136 lines (112 sloc) 3.28 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(**
Http dialog component
@author Cedric Soulas
*)

(**
This module reply to an http client request via the provided dialog function.
This module is a RuntimeSig.COMPONENT.
*)

(** {6 Types and functions to comply with RuntimeSig.COMPONENT} *)

type t
  (** Internal type *)

type port = {
  set_dialog : t -> unit
}
    (**
Port to be used by http server via the runtime layer.
See [RuntimeType.Ports.t].
*)


type dialog = Scheduler.t -> HttpServerTypes.web_info -> unit

type options = {
  opt_allowed : Unix.inet_addr -> bool;
  dialog_name : string;
  dialog : unit -> dialog;
  opt_url_prefix : string;
}
    (**
Type to define the http dialog.
See [make].
*)
val name : string
val version : string

val default_options : options
  (**
Default options of the http dialog.
[options_with_dialog] can be used to define a dialog.
Default options are:
opt_allowed always return true,
dialog_name is "default",
dialog is null,
opt_url_prefix is empty.
*)

val spec_args : string -> (options ServerArg.arg_parser) list
  (**
Return the command line parser specification.
*)

val make : string -> options -> Scheduler.t -> t
  (**
[make name options sched] make a fresh [t] from provided name and options.
The name is used to prefix the command line options.
*)

val run :
  t ->
  Scheduler.t ->
  t
    (**
Run the http dialog.
It forces the evaluation of the provided dialog function.
*)

val get_ports :
  t ->
  Scheduler.t ->
  (string * [> ]) list
  (**
This function return an empty port declaration (the http dialog accepts no port),
to comply with [RuntimeSig.COMPONENT].
*)

val get_description :
  t ->
  Scheduler.t ->
  [> `HttpDialog of t]
    (**
Return an http dialog description, to comply with [RuntimeSig.COMPONENT].
*)

val close :
  t ->
  Scheduler.t ->
  unit
    (**
This function does nothing, but it complies with [RuntimeSig.COMPONENT].
*)

(** {6 Misc.} *)

val options_with_dialog : (unit -> dialog) -> options
  (**
Return a [default_options] but with the provided dialog.
*)

val body : t -> Scheduler.t -> HttpServerTypes.web_info -> unit
  (**
Reply to an http client request via the provided [HttpServerTypes.web_info].
*)

val content : t -> (string -> int -> int -> unit)
  (**
Deprecated.
It was used for upload progress information.
*)

val is_allowed : t -> Scheduler.connection_info -> bool
  (**
Deprecated.
It was used to check if [Scheduler.connection_info] is allowed to receive a response.
*)
Something went wrong with that request. Please try again.