From 78fb608c3ad94c6084dce1295672d9c4fc595b75 Mon Sep 17 00:00:00 2001 From: Sora Morimoto Date: Tue, 24 Dec 2024 11:25:49 +0900 Subject: [PATCH] Update ocamlformat to 0.27.0 Signed-off-by: Sora Morimoto --- .ocamlformat | 65 ++++++++-------- src/baselib/dynlink_wrapper.natdynlink.ml | 2 +- src/baselib/dynlink_wrapper.nonatdynlink.ml | 2 +- src/baselib/ocsigen_cache.ml | 8 +- src/baselib/ocsigen_cache.mli | 2 +- src/baselib/ocsigen_lib.ml | 8 +- src/baselib/ocsigen_lib.mli | 2 +- src/baselib/ocsigen_lib_base.ml | 2 +- src/baselib/ocsigen_lib_base.mli | 2 +- src/baselib/ocsigen_loader.ml | 23 +++--- src/baselib/ocsigen_loader.mli | 2 +- src/baselib/ocsigen_stream.ml | 4 +- src/baselib/ocsigen_stream.mli | 2 +- src/baselib/polytables/polytables.ml | 2 +- src/baselib/polytables/polytables.mli | 2 +- src/extensions/accesscontrol.ml | 20 ++--- src/extensions/accesscontrol.mli | 2 +- src/extensions/authbasic.ml | 2 +- src/extensions/authbasic.mli | 2 +- src/extensions/cors.ml | 2 +- src/extensions/deflatemod.ml | 2 +- src/extensions/extendconfiguration.ml | 13 +++- src/extensions/outputfilter.ml | 2 +- src/extensions/redirectmod.ml | 2 +- src/extensions/revproxy.ml | 18 +++-- src/extensions/rewritemod.ml | 6 +- src/extensions/staticmod.ml | 10 ++- src/extensions/userconf.ml | 11 +-- src/http/ocsigen_charset_mime.ml | 2 +- src/http/ocsigen_charset_mime.mli | 2 +- src/http/ocsigen_cookie_map.ml | 2 +- src/http/ocsigen_cookie_map.mli | 2 +- src/http/ocsigen_header.ml | 2 +- src/http/ocsigen_header.mli | 2 +- src/server/ocsigen_cohttp.ml | 14 ++-- src/server/ocsigen_command.ml | 8 +- src/server/ocsigen_command.mli | 2 +- src/server/ocsigen_config.ml | 2 +- src/server/ocsigen_config.mli | 2 +- src/server/ocsigen_extensions.ml | 64 +++++++++++----- src/server/ocsigen_extensions.mli | 8 +- src/server/ocsigen_local_files.ml | 26 ++++--- src/server/ocsigen_local_files.mli | 2 +- src/server/ocsigen_messages.ml | 14 ++-- src/server/ocsigen_messages.mli | 2 +- src/server/ocsigen_multipart.ml | 58 +++++++------- src/server/ocsigen_parseconfig.ml | 9 ++- src/server/ocsigen_parseconfig.mli | 2 +- src/server/ocsigen_request.ml | 52 +++++++++---- src/server/ocsigen_response.ml | 18 +++-- src/server/ocsigen_server.ml | 83 +++++++++++++++------ src/server/ocsigen_server.mli | 2 +- 52 files changed, 367 insertions(+), 233 deletions(-) diff --git a/.ocamlformat b/.ocamlformat index f7747f88a..3a58f51a7 100644 --- a/.ocamlformat +++ b/.ocamlformat @@ -1,32 +1,33 @@ -version=0.26.2 -break-cases = fit -break-collection-expressions = fit-or-vertical -break-fun-decl = wrap -break-fun-sig = wrap -break-infix = wrap -break-infix-before-func = false -break-sequences = false -break-separators = before -break-string-literals = never -break-struct = force -cases-matching-exp-indent = compact -doc-comments = after-when-possible -dock-collection-brackets = false -indicate-multiline-delimiters = no -infix-precedence = indent -let-and = compact -let-binding-spacing = compact -module-item-spacing = compact -parens-tuple = multi-line-only -parens-tuple-patterns = multi-line-only -sequence-style = terminator -sequence-blank-line = compact -single-case = compact -type-decl = compact -if-then-else = keyword-first -field-space = loose -space-around-arrays = false -space-around-records = false -space-around-lists = false -space-around-variants = false -ocp-indent-compat = true +version=0.27.0 +break-cases=fit +break-collection-expressions=fit-or-vertical +break-fun-decl=wrap +break-fun-sig=wrap +break-infix-before-func=false +break-infix=wrap +break-separators=before +break-sequences=false +break-string-literals=never +break-struct=force +cases-matching-exp-indent=compact +doc-comments=after-when-possible +dock-collection-brackets=false +field-space=loose +if-then-else=keyword-first +indicate-multiline-delimiters=no +infix-precedence=indent +let-and=compact +let-binding-spacing=compact +module-item-spacing=compact +ocp-indent-compat=true +parens-tuple-patterns=multi-line-only +parens-tuple=multi-line-only +parse-docstrings=false +sequence-blank-line=compact +sequence-style=terminator +single-case=compact +space-around-arrays=false +space-around-lists=false +space-around-records=false +space-around-variants=false +type-decl=compact diff --git a/src/baselib/dynlink_wrapper.natdynlink.ml b/src/baselib/dynlink_wrapper.natdynlink.ml index a4e044375..75b30e9a1 100644 --- a/src/baselib/dynlink_wrapper.natdynlink.ml +++ b/src/baselib/dynlink_wrapper.natdynlink.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) open Dynlink diff --git a/src/baselib/dynlink_wrapper.nonatdynlink.ml b/src/baselib/dynlink_wrapper.nonatdynlink.ml index 92128378e..f3e2007bf 100644 --- a/src/baselib/dynlink_wrapper.nonatdynlink.ml +++ b/src/baselib/dynlink_wrapper.nonatdynlink.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) exception Error of string diff --git a/src/baselib/ocsigen_cache.ml b/src/baselib/ocsigen_cache.ml index 608c15b26..2aedf39c4 100644 --- a/src/baselib/ocsigen_cache.ml +++ b/src/baselib/ocsigen_cache.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Cache. @@ -124,9 +124,9 @@ end = struct ; mutable maxsize : int ; mutable finaliser_before : 'a node -> unit ; mutable finaliser_after : 'a node -> unit - ; (* *) time_bound : time_bound option } + ; time_bound : time_bound option } - and time_bound = {(* *) timer : float; mutable collector : unit Lwt.t option} + and time_bound = {timer : float; mutable collector : unit Lwt.t option} (* Checks (by BY): @@ -435,7 +435,7 @@ functor ; mutable table : (A.value * A.key Dlist.node) H.t ; finder : A.key -> A.value Lwt.t ; clear : unit -> unit - (* This function clears the cache. It is put inside the + (* This function clears the cache. It is put inside the cache structure so that it is garbage-collected only when the cache is no longer referenced, as the functions themselves are put inside a weak hash table *) diff --git a/src/baselib/ocsigen_cache.mli b/src/baselib/ocsigen_cache.mli index 79299ad98..24c18dd75 100644 --- a/src/baselib/ocsigen_cache.mli +++ b/src/baselib/ocsigen_cache.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Cache. diff --git a/src/baselib/ocsigen_lib.ml b/src/baselib/ocsigen_lib.ml index 0f7073e2a..fd597cc82 100644 --- a/src/baselib/ocsigen_lib.ml +++ b/src/baselib/ocsigen_lib.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) include Ocsigen_lib_base module String = String_base @@ -69,8 +69,9 @@ module Filename = struct then String.sub filename (pos + 1) (String.length filename - pos - 1) else (* Dot before a directory separator *) raise Not_found - with Not_found -> (* No dot in filename *) - raise Not_found + with Not_found -> + (* No dot in filename *) + raise Not_found end (*****************************************************************************) @@ -399,7 +400,6 @@ module Url = struct https, host, port, path, query in (* Note that the fragment (string after #) is not sent by browsers *) - (*20110707 ' ' is encoded to '+' in queries, but not in paths. Warning: if we write the URL manually, we must encode ' ' to '+' manually (not done by the browser). diff --git a/src/baselib/ocsigen_lib.mli b/src/baselib/ocsigen_lib.mli index 27c864522..b7dea6d0b 100644 --- a/src/baselib/ocsigen_lib.mli +++ b/src/baselib/ocsigen_lib.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** This module contains some auxiliaries for the Ocsigenserver. In contrast to {!Ocsigen_lib_base}, the function may also refer to libraries other than the diff --git a/src/baselib/ocsigen_lib_base.ml b/src/baselib/ocsigen_lib_base.ml index 0404d37fe..e62cab28a 100644 --- a/src/baselib/ocsigen_lib_base.ml +++ b/src/baselib/ocsigen_lib_base.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) exception Ocsigen_Internal_Error of string exception Input_is_too_large diff --git a/src/baselib/ocsigen_lib_base.mli b/src/baselib/ocsigen_lib_base.mli index 968061ae6..d5251dcb4 100644 --- a/src/baselib/ocsigen_lib_base.mli +++ b/src/baselib/ocsigen_lib_base.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** This module just contains only extensions of the standard library and very basic Ocsigen values and exceptions. Cf. {!Ocsigen_lib} for functionality diff --git a/src/baselib/ocsigen_loader.ml b/src/baselib/ocsigen_loader.ml index a0df48fc0..35a30b03c 100644 --- a/src/baselib/ocsigen_loader.ml +++ b/src/baselib/ocsigen_loader.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) open Ocsigen_lib @@ -33,18 +33,19 @@ let translate = if Ocsigen_config_static.is_native then fun filename -> - if Filename.check_suffix filename ".cmo" - || Filename.check_suffix filename ".cma" - then Filename.chop_extension filename ^ ".cmxs" - else filename + if + Filename.check_suffix filename ".cmo" + || Filename.check_suffix filename ".cma" + then Filename.chop_extension filename ^ ".cmxs" + else filename else fun filename -> - if Filename.check_suffix filename ".cmxs" - then - let filename = Filename.chop_extension filename in - let cma = filename ^ ".cma" in - if Sys.file_exists cma then cma else filename ^ ".cmo" - else filename + if Filename.check_suffix filename ".cmxs" + then + let filename = Filename.chop_extension filename in + let cma = filename ^ ".cma" in + if Sys.file_exists cma then cma else filename ^ ".cmo" + else filename (************************************************************************) (* Loading files *) diff --git a/src/baselib/ocsigen_loader.mli b/src/baselib/ocsigen_loader.mli index 1d4a7bf0a..9f8b8c51b 100644 --- a/src/baselib/ocsigen_loader.mli +++ b/src/baselib/ocsigen_loader.mli @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Module [Ocsigen_loader]: Dynamic loading for Ocsigen. *) diff --git a/src/baselib/ocsigen_stream.ml b/src/baselib/ocsigen_stream.ml index 18c7c5606..cc676d0fa 100644 --- a/src/baselib/ocsigen_stream.ml +++ b/src/baselib/ocsigen_stream.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) open Ocsigen_lib @@ -154,7 +154,7 @@ let rec stream_want s len = Lwt.catch (fun () -> enlarge_stream s >>= fun r -> Lwt.return (`OK r)) (function - | Stream_too_small -> Lwt.return `Too_small | e -> Lwt.fail e) + | Stream_too_small -> Lwt.return `Too_small | e -> Lwt.fail e) >>= function | `OK r -> stream_want r len | `Too_small -> Lwt.return s) diff --git a/src/baselib/ocsigen_stream.mli b/src/baselib/ocsigen_stream.mli index ed409d4ea..31ec51136 100644 --- a/src/baselib/ocsigen_stream.mli +++ b/src/baselib/ocsigen_stream.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) exception Interrupted of exn exception Cancelled diff --git a/src/baselib/polytables/polytables.ml b/src/baselib/polytables/polytables.ml index 4ac945a01..b8a2bc5a2 100644 --- a/src/baselib/polytables/polytables.ml +++ b/src/baselib/polytables/polytables.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** @author Vincent Balat @author Jérôme Vouillon diff --git a/src/baselib/polytables/polytables.mli b/src/baselib/polytables/polytables.mli index 22bd3594f..dabec0551 100644 --- a/src/baselib/polytables/polytables.mli +++ b/src/baselib/polytables/polytables.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Polymorphic tables (using Map) @author Vincent Balat diff --git a/src/extensions/accesscontrol.ml b/src/extensions/accesscontrol.ml index a6641f82a..c59307198 100644 --- a/src/extensions/accesscontrol.ml +++ b/src/extensions/accesscontrol.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (* Filtering requests via the configuration file *) @@ -368,10 +368,11 @@ let parse_config parse_fun = function | Ocsigen_extensions.Req_found (_, r) -> Lwt.return (Ocsigen_extensions.Ext_found (fun () -> Lwt.return r)) | Ocsigen_extensions.Req_not_found (err, _ri) -> - if let err = - string_of_int Cohttp.Code.(code_of_status (err :> status_code)) - in - Netstring_pcre.string_match re err 0 <> None + if + let err = + string_of_int Cohttp.Code.(code_of_status (err :> status_code)) + in + Netstring_pcre.string_match re err 0 <> None then Lwt.return (Ocsigen_extensions.Ext_sub_result ext) else Lwt.return (Ocsigen_extensions.Ext_next err)) | Element (("ifnotfound" as s), _, _) -> @@ -433,10 +434,11 @@ let ifnotfound ?code instrs vh ci p = (Ocsigen_extensions.Ext_sub_result (Ocsigen_extensions.compose (List.map (fun i -> i vh ci p) instrs))) | Some re -> - if let err = - string_of_int Cohttp.Code.(code_of_status (err :> status_code)) - in - Netstring_pcre.string_match re err 0 <> None + if + let err = + string_of_int Cohttp.Code.(code_of_status (err :> status_code)) + in + Netstring_pcre.string_match re err 0 <> None then Lwt.return (Ocsigen_extensions.Ext_sub_result diff --git a/src/extensions/accesscontrol.mli b/src/extensions/accesscontrol.mli index 4b4723359..d36ddda73 100644 --- a/src/extensions/accesscontrol.mli +++ b/src/extensions/accesscontrol.mli @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Accesscontrol: Conditional access to some sites *) diff --git a/src/extensions/authbasic.ml b/src/extensions/authbasic.ml index ea2670dbd..46788bca6 100644 --- a/src/extensions/authbasic.ml +++ b/src/extensions/authbasic.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) open Lwt.Infix diff --git a/src/extensions/authbasic.mli b/src/extensions/authbasic.mli index c732beaeb..6b42df266 100644 --- a/src/extensions/authbasic.mli +++ b/src/extensions/authbasic.mli @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Authbasic: Basic HTTP authentication *) diff --git a/src/extensions/cors.ml b/src/extensions/cors.ml index 273f2a059..2247aa416 100644 --- a/src/extensions/cors.ml +++ b/src/extensions/cors.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Handle Cross-Origin Resource Sharing (CORS) headers *) diff --git a/src/extensions/deflatemod.ml b/src/extensions/deflatemod.ml index 76fe927ba..11abca8cc 100644 --- a/src/extensions/deflatemod.ml +++ b/src/extensions/deflatemod.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (* Compress output sent by the server *) diff --git a/src/extensions/extendconfiguration.ml b/src/extensions/extendconfiguration.ml index bfd28cf0b..b21cbf08b 100644 --- a/src/extensions/extendconfiguration.ml +++ b/src/extensions/extendconfiguration.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) let name = "extendconfiguration" let bad_config s = raise (Ocsigen_extensions.Error_in_config_file s) @@ -275,8 +275,15 @@ let defaultindex v _ _ _ = gen @@ fun config -> {config with Ocsigen_extensions.default_directory_index = v} -let contenttype ?default ?(files = []) ?(extensions = []) ?(regexps = []) () _ _ - _ +let contenttype + ?default + ?(files = []) + ?(extensions = []) + ?(regexps = []) + () + _ + _ + _ = gen @@ fun config -> let mime_assoc = config.Ocsigen_extensions.mime_assoc in diff --git a/src/extensions/outputfilter.ml b/src/extensions/outputfilter.ml index 3d52fa7d7..03bcdd4b9 100644 --- a/src/extensions/outputfilter.ml +++ b/src/extensions/outputfilter.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (* This module enables rewritting the server output *) diff --git a/src/extensions/redirectmod.ml b/src/extensions/redirectmod.ml index 8c5fdcc43..9c3ee53ca 100644 --- a/src/extensions/redirectmod.ml +++ b/src/extensions/redirectmod.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (* Define page redirections in the configuration file *) diff --git a/src/extensions/revproxy.ml b/src/extensions/revproxy.ml index d49c9a541..9ccaf3eec 100644 --- a/src/extensions/revproxy.ml +++ b/src/extensions/revproxy.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Reverse proxy for Ocsigen @@ -35,8 +35,12 @@ type redirection = ; keephost : bool } (** The table of redirections for each virtual server *) -let create_redirection ?(full_url = true) ?(pipeline = true) ?(keephost = false) - ~regexp dest +let create_redirection + ?(full_url = true) + ?(pipeline = true) + ?(keephost = false) + ~regexp + dest = let regexp = Pcre.regexp ("^" ^ regexp ^ "$") in {regexp; dest; full_url; pipeline; keephost} @@ -49,7 +53,7 @@ let gen dir = function -> Lwt.catch (* Is it a redirection? *) - (fun () -> + (fun () -> Lwt_log.ign_info ~section "Is it a redirection?"; let dest = Ocsigen_extensions.find_redirection dir.regexp dir.full_url @@ -134,9 +138,9 @@ let gen dir = function @@ Ocsigen_extensions.Ext_found (fun () -> do_request () >|= Ocsigen_response.of_cohttp)) (function - | Ocsigen_extensions.Not_concerned -> - Lwt.return (Ocsigen_extensions.Ext_next err) - | e -> Lwt.fail e) + | Ocsigen_extensions.Not_concerned -> + Lwt.return (Ocsigen_extensions.Ext_next err) + | e -> Lwt.fail e) let parse_config config_elem = let regexp = ref None in diff --git a/src/extensions/rewritemod.ml b/src/extensions/rewritemod.ml index a8e272f82..d7d226b5e 100644 --- a/src/extensions/rewritemod.ml +++ b/src/extensions/rewritemod.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (* Rewrite URLs in the configuration file *) @@ -99,8 +99,8 @@ let parse_config element = ~elements: [ Configuration.element ~name:"rewrite" ~attributes: - [ Configuration.attribute ~name:"regexp" ~obligatory:true - (fun s -> regexp := s) + [ Configuration.attribute ~name:"regexp" ~obligatory:true (fun s -> + regexp := s) ; Configuration.attribute ~name:"url" (fun s -> dest := Some s) ; Configuration.attribute ~name:"dest" (fun s -> dest := Some s) ; Configuration.attribute ~name:"fullrewrite" (fun s -> diff --git a/src/extensions/staticmod.ml b/src/extensions/staticmod.ml index a6af87930..744d8deaf 100644 --- a/src/extensions/staticmod.ml +++ b/src/extensions/staticmod.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) open Lwt.Infix module Pcre = Re.Pcre @@ -71,8 +71,12 @@ let correct_user_local_file = If the parameter [usermode] is true, we check that the path is valid. *) -let find_static_page ~request ~usermode ~dir ~(err : Cohttp.Code.status) - ~pathstring +let find_static_page + ~request + ~usermode + ~dir + ~(err : Cohttp.Code.status) + ~pathstring = let status_filter, filename, root = match dir with diff --git a/src/extensions/userconf.ml b/src/extensions/userconf.ml index 472d85a24..257e32f51 100644 --- a/src/extensions/userconf.ml +++ b/src/extensions/userconf.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (* Local (users) config files *) @@ -156,12 +156,9 @@ let parse_config _ hostpattern _ path _ _ config_elem = ~elements: [ Configuration.element ~name:"userconf" ~attributes: - [ Configuration.attribute ~name:"regexp" ~obligatory:true - (fun s -> - let s = - Ocsigen_lib.Netstring_pcre.regexp ("^" ^ s ^ "$") - in - regexp := Some s) + [ Configuration.attribute ~name:"regexp" ~obligatory:true (fun s -> + let s = Ocsigen_lib.Netstring_pcre.regexp ("^" ^ s ^ "$") in + regexp := Some s) ; Configuration.attribute ~name:"conf" ~obligatory:true (fun s -> let s = Ocsigen_extensions.parse_user_dir s in conf := Some s) diff --git a/src/http/ocsigen_charset_mime.ml b/src/http/ocsigen_charset_mime.ml index 8a5287114..e9f8bceb7 100644 --- a/src/http/ocsigen_charset_mime.ml +++ b/src/http/ocsigen_charset_mime.ml @@ -17,7 +17,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) open Ocsigen_lib module MapString = Map.Make (String) diff --git a/src/http/ocsigen_charset_mime.mli b/src/http/ocsigen_charset_mime.mli index 5d3c63ae3..6f08c9764 100644 --- a/src/http/ocsigen_charset_mime.mli +++ b/src/http/ocsigen_charset_mime.mli @@ -17,7 +17,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) type extension = string type file = string diff --git a/src/http/ocsigen_cookie_map.ml b/src/http/ocsigen_cookie_map.ml index 8f030ebac..2cde3d562 100644 --- a/src/http/ocsigen_cookie_map.ml +++ b/src/http/ocsigen_cookie_map.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) module Map_path = Map.Make (struct type t = string list diff --git a/src/http/ocsigen_cookie_map.mli b/src/http/ocsigen_cookie_map.mli index 0ecde492b..5f12a3bd9 100644 --- a/src/http/ocsigen_cookie_map.mli +++ b/src/http/ocsigen_cookie_map.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) module Map_path : Map.S with type key := Ocsigen_lib_base.Url_base.path (** This type of maps is used to store cookie values for each diff --git a/src/http/ocsigen_header.ml b/src/http/ocsigen_header.ml index f7f452491..0073562d6 100644 --- a/src/http/ocsigen_header.ml +++ b/src/http/ocsigen_header.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) type t = Cohttp.Header.t diff --git a/src/http/ocsigen_header.mli b/src/http/ocsigen_header.mli index b321a137a..42440933f 100644 --- a/src/http/ocsigen_header.mli +++ b/src/http/ocsigen_header.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) type t = Cohttp.Header.t diff --git a/src/server/ocsigen_cohttp.ml b/src/server/ocsigen_cohttp.ml index 71618b673..66895339a 100644 --- a/src/server/ocsigen_cohttp.ml +++ b/src/server/ocsigen_cohttp.ml @@ -187,13 +187,13 @@ let handler ~ssl ~address ~port ~connector (flow, conn) request body = in Lwt.return (response, body)) (function - | Ocsigen_is_dir fun_request -> - let headers = - fun_request request |> Uri.to_string - |> Cohttp.Header.init_with "location" - and status = `Moved_permanently in - Cohttp_lwt_unix.Server.respond ~headers ~status ~body:`Empty () - | exn -> handle_error exn)) + | Ocsigen_is_dir fun_request -> + let headers = + fun_request request |> Uri.to_string + |> Cohttp.Header.init_with "location" + and status = `Moved_permanently in + Cohttp_lwt_unix.Server.respond ~headers ~status ~body:`Empty () + | exn -> handle_error exn)) (fun () -> if !filenames <> [] then diff --git a/src/server/ocsigen_command.ml b/src/server/ocsigen_command.ml index fbe38f8b3..1f477d9ea 100644 --- a/src/server/ocsigen_command.ml +++ b/src/server/ocsigen_command.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) exception Unknown_command @@ -30,9 +30,9 @@ let register_command_function, get_command_function = Lwt.catch (fun () -> old_command_function ?prefix s c) (function - | Unknown_command -> - if prefix = prefix' then f s c else Lwt.fail Unknown_command - | e -> Lwt.fail e)) + | Unknown_command -> + if prefix = prefix' then f s c else Lwt.fail Unknown_command + | e -> Lwt.fail e)) , fun () -> !command_function ) let () = diff --git a/src/server/ocsigen_command.mli b/src/server/ocsigen_command.mli index a4af753c7..81603782d 100644 --- a/src/server/ocsigen_command.mli +++ b/src/server/ocsigen_command.mli @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Extending server commands *) diff --git a/src/server/ocsigen_config.ml b/src/server/ocsigen_config.ml index 570e0b37b..2eb04838a 100644 --- a/src/server/ocsigen_config.ml +++ b/src/server/ocsigen_config.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) include Ocsigen_config_static diff --git a/src/server/ocsigen_config.mli b/src/server/ocsigen_config.mli index f0322f5e0..9d4fb0935 100644 --- a/src/server/ocsigen_config.mli +++ b/src/server/ocsigen_config.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Configuring Ocsigen server *) diff --git a/src/server/ocsigen_extensions.ml b/src/server/ocsigen_extensions.ml index 3eb0737b9..54604b88f 100644 --- a/src/server/ocsigen_extensions.ml +++ b/src/server/ocsigen_extensions.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) let section = Lwt_log.Section.make "ocsigen:ext" @@ -133,7 +133,7 @@ type config_info = ; mime_assoc : Ocsigen_charset_mime.mime_assoc ; charset_assoc : Ocsigen_charset_mime.charset_assoc ; default_directory_index : string list - (** Default name to use as index file + (** Default name to use as index file when a directory is requested. Use [None] if no index should be tried. The various indexes are @@ -144,11 +144,11 @@ type config_info = according to [list_directry_content] *) ; list_directory_content : bool - (** Should the list of files in a directory be + (** Should the list of files in a directory be displayed if there is no index in this directory ? *) ; follow_symlinks : [`No | `Owner_match | `Always] - (** Should symlinks be + (** Should symlinks be followed when accessign a local file? *) ; do_not_serve_404 : do_not_serve @@ -279,7 +279,7 @@ let get_hostname {request_info; request_config = {default_hostname; _}; _} = - or the port in the Host header - or the default port set in the configuration file. *) let get_port - {request_info; request_config = {default_httpport; default_httpsport; _}} + {request_info; request_config = {default_httpport; default_httpsport; _}} = if Ocsigen_config.get_usedefaulthostname () then @@ -496,8 +496,13 @@ let preprocess_site_path p = (* Implements only parsing. Uses parse_host to recursively parse children of . *) -let default_parse_config _userconf_info (_host : virtual_hosts) _config_info - prevpath (Parse_host parse_host) (_parse_fun : parse_fun) +let default_parse_config + _userconf_info + (_host : virtual_hosts) + _config_info + prevpath + (Parse_host parse_host) + (_parse_fun : parse_fun) = function | Xml.Element ("site", atts, l) -> let charset, dir = parse_site_attrs (None, None) atts in @@ -562,8 +567,14 @@ let default_parse_extension ext_name = function "Unexpected content found in configuration of extension %s: %s does not accept options" ext_name ext_name)) -let register ~name ?fun_site ?end_init ?init_fun ?exn_handler ?respect_pipeline - () +let register + ~name + ?fun_site + ?end_init + ?init_fun + ?exn_handler + ?respect_pipeline + () = Ocsigen_loader.set_module_init_function name (fun () -> (match init_fun with @@ -589,8 +600,16 @@ module Configuration = struct and element = string * element' - let element ~name ?(obligatory = false) ?(init = ignore) ?(elements = []) - ?(attributes = []) ?pcdata ?other_elements ?other_attributes () : element + let element + ~name + ?(obligatory = false) + ?(init = ignore) + ?(elements = []) + ?(attributes = []) + ?pcdata + ?other_elements + ?other_attributes + () : element = ( name , { obligatory @@ -638,8 +657,11 @@ module Configuration = struct ("Obligatory element " ^ name ^ " not in tag " ^ in_tag)) | _ -> () - let process_attribute ~in_tag ~attributes:spec_attributes - ?other_attributes:spec_other_attributes (attribute, value) + let process_attribute + ~in_tag + ~attributes:spec_attributes + ?other_attributes:spec_other_attributes + (attribute, value) = try (List.assoc attribute spec_attributes).attribute_value_func value with Not_found -> ( @@ -650,8 +672,11 @@ module Configuration = struct (Error_in_user_config_file ("Unexpected attribute " ^ attribute ^ " in tag " ^ in_tag))) - let rec process_element ~in_tag ~elements:spec_elements ?pcdata:spec_pcdata - ?other_elements:spec_other_elements + let rec process_element + ~in_tag + ~elements:spec_elements + ?pcdata:spec_pcdata + ?other_elements:spec_other_elements = function | Xml.PCData str -> let spec_pcdata = @@ -685,8 +710,13 @@ module Configuration = struct (Error_in_config_file ("Unknown tag " ^ name ^ " in tag " ^ in_tag))) ) - let process_elements ~in_tag ~elements:spec_elements ?pcdata ?other_elements - ?(init = ignore) elements + let process_elements + ~in_tag + ~elements:spec_elements + ?pcdata + ?other_elements + ?(init = ignore) + elements = List.iter (check_element_occurrence ~in_tag elements) spec_elements; init (); diff --git a/src/server/ocsigen_extensions.mli b/src/server/ocsigen_extensions.mli index 018abf237..946ea0910 100644 --- a/src/server/ocsigen_extensions.mli +++ b/src/server/ocsigen_extensions.mli @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Extensions interface for Ocsigen Server *) @@ -91,16 +91,16 @@ type config_info = ; mime_assoc : Ocsigen_charset_mime.mime_assoc ; charset_assoc : Ocsigen_charset_mime.charset_assoc ; default_directory_index : string list - (** Default name to use as index file when a directory is requested. + (** Default name to use as index file when a directory is requested. Use [None] if no index should be tried. The various indexes are tried in the given order. If no index is specified, or the index does not exists, the content of the directory might be listed, according to [list_directory_content] *) ; list_directory_content : bool - (** Should the list of files in a directory be displayed if there is + (** Should the list of files in a directory be displayed if there is no index in this directory ? *) ; follow_symlinks : [`No | `Owner_match | `Always] - (** Should symlinks be followed when accessing a local file? *) + (** Should symlinks be followed when accessing a local file? *) ; do_not_serve_404 : do_not_serve ; do_not_serve_403 : do_not_serve ; uploaddir : string option diff --git a/src/server/ocsigen_local_files.ml b/src/server/ocsigen_local_files.ml index 862f4cc6b..5b5c0235e 100644 --- a/src/server/ocsigen_local_files.ml +++ b/src/server/ocsigen_local_files.ml @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (* Display of a local file or directory. Currently used in staticmod and eliom_predefmod *) @@ -40,8 +40,10 @@ let follow_symlinks_if_owner_match : symlink_policy = of calling [stat] and [lstat] on filenam. If supplied, [stat] must be the result of calling [Unix.stat] on [filename] *) -let check_symlinks_aux filename ?(stat = Unix.LargeFile.stat filename) - (policy : symlink_policy) +let check_symlinks_aux + filename + ?(stat = Unix.LargeFile.stat filename) + (policy : symlink_policy) = let lstat = Unix.LargeFile.lstat filename in if lstat.Unix.LargeFile.st_kind = Unix.S_LNK @@ -50,8 +52,10 @@ let check_symlinks_aux filename ?(stat = Unix.LargeFile.stat filename) (* Check that there are no invalid symlinks in the directories leading to [filename]. Paths upwards [no_check_for] are not checked. *) -let rec check_symlinks_parent_directories ~filename ~no_check_for - (policy : symlink_policy) +let rec check_symlinks_parent_directories + ~filename + ~no_check_for + (policy : symlink_policy) = if filename = "/" || filename = "." || Some filename = no_check_for then true @@ -141,8 +145,11 @@ type resolved = RFile of string | RDir of string - otherwise returns [filename] *) (* See also module Files in eliom.ml *) -let resolve ?no_check_for - ~request:({Ocsigen_extensions.request_config; _} as request) ~filename () +let resolve + ?no_check_for + ~request:({Ocsigen_extensions.request_config; _} as request) + ~filename + () = (* We only accept absolute filenames in daemon mode, as we do not really know what is the current directory *) @@ -193,8 +200,9 @@ let resolve ?no_check_for Lwt_log.ign_info_f ~section "Filenames cannot contain .. as in \"%s\"." filename; raise Failed_403) - else if check_symlinks ~filename ~no_check_for - request_config.Ocsigen_extensions.follow_symlinks + else if + check_symlinks ~filename ~no_check_for + request_config.Ocsigen_extensions.follow_symlinks then ( can_send filename request_config; (* If the previous function did not fail, we are authorized to diff --git a/src/server/ocsigen_local_files.mli b/src/server/ocsigen_local_files.mli index 649a77a32..a3bb43c06 100644 --- a/src/server/ocsigen_local_files.mli +++ b/src/server/ocsigen_local_files.mli @@ -15,7 +15,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) val section : Lwt_log_core.section (** use Lwt_log.Section.set_level in order to debug *) diff --git a/src/server/ocsigen_messages.ml b/src/server/ocsigen_messages.ml index a94030df3..137b81fe5 100644 --- a/src/server/ocsigen_messages.ml +++ b/src/server/ocsigen_messages.ml @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Writing messages in the logs *) @@ -47,12 +47,12 @@ let open_files () = Lwt.catch (fun () -> Lwt_log.file ~file_name:path ()) (function - | Unix.Unix_error (error, _, _) -> - Lwt.fail - (Ocsigen_config.Config_file_error - (Printf.sprintf "can't open log file %s: %s" path - (Unix.error_message error))) - | exn -> Lwt.fail exn) + | Unix.Unix_error (error, _, _) -> + Lwt.fail + (Ocsigen_config.Config_file_error + (Printf.sprintf "can't open log file %s: %s" path + (Unix.error_message error))) + | exn -> Lwt.fail exn) in open_log access_file >>= fun acc -> access_logger := acc; diff --git a/src/server/ocsigen_messages.mli b/src/server/ocsigen_messages.mli index 3aee6b748..c05511cc3 100644 --- a/src/server/ocsigen_messages.mli +++ b/src/server/ocsigen_messages.mli @@ -14,7 +14,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Writing messages in the logs *) diff --git a/src/server/ocsigen_multipart.ml b/src/server/ocsigen_multipart.ml index 119d26883..e530c29e3 100644 --- a/src/server/ocsigen_multipart.ml +++ b/src/server/ocsigen_multipart.ml @@ -27,8 +27,13 @@ let header_unstripped_re = S.regexp "([^ \t\r\n:]+):([ \t]*.*\n([ \t].*\n)*)" let empty_line_re = S.regexp "\013?\n" let end_of_header_re = S.regexp "\n\013?\n" -let scan_header ?(downcase = true) ?(unfold = true) ?(strip = false) parstr - ~start_pos ~end_pos +let scan_header + ?(downcase = true) + ?(unfold = true) + ?(strip = false) + parstr + ~start_pos + ~end_pos = let header_re = if unfold || strip then header_stripped_re else header_unstripped_re @@ -72,12 +77,12 @@ let read_header ?downcase ?unfold ?strip s = Lwt.return (s, match_end (snd (S.search_forward end_of_header_re b 0)))) (function - | Not_found -> ( - Ocsigen_stream.enlarge_stream s >>= function - | Ocsigen_stream.Finished _ -> - Lwt.fail Ocsigen_stream.Stream_too_small - | Ocsigen_stream.Cont _ as s -> find_end_of_header s) - | e -> Lwt.fail e) + | Not_found -> ( + Ocsigen_stream.enlarge_stream s >>= function + | Ocsigen_stream.Finished _ -> + Lwt.fail Ocsigen_stream.Stream_too_small + | Ocsigen_stream.Cont _ as s -> find_end_of_header s) + | e -> Lwt.fail e) in find_end_of_header s >>= fun (s, end_pos) -> let b = Ocsigen_stream.current_buffer s in @@ -101,11 +106,11 @@ let search_end_of_line s k = (fun () -> search_window s lf_re k >>= fun (s, x) -> Lwt.return (s, match_end x)) (function - | Not_found -> - Lwt.fail - (Multipart_error - "read_multipart_body: MIME boundary without line end") - | e -> Lwt.fail e) + | Not_found -> + Lwt.fail + (Multipart_error + "read_multipart_body: MIME boundary without line end") + | e -> Lwt.fail e) let search_first_boundary ~boundary s = (* Search boundary per regexp; return the position of the @@ -180,10 +185,10 @@ let read_multipart_body ~boundary ~decode_part s = (* Begin with first part: *) parse_parts ~boundary ~decode_part s uses_crlf) (function - | Not_found -> - (* No boundary at all, empty body *) - Lwt.return [] - | e -> Lwt.fail e) + | Not_found -> + (* No boundary at all, empty body *) + Lwt.return [] + | e -> Lwt.fail e) let empty_stream = Ocsigen_stream.get (Ocsigen_stream.make (fun () -> Ocsigen_stream.empty None)) @@ -197,9 +202,10 @@ let decode_part ~max_size ~create ~add ~stop stream = | Ocsigen_stream.Cont (stri, f) -> let long = String.length stri in let size2 = Int64.add size (Int64.of_int long) in - if match max_size with - | None -> false - | Some m -> Int64.compare size2 m > 0 + if + match max_size with + | None -> false + | Some m -> Int64.compare size2 m > 0 then Lwt.fail Ocsigen_lib.Ocsigen_Request_too_long else if stri = "" then Ocsigen_stream.next f >>= while_stream size @@ -220,9 +226,9 @@ let scan_multipart_body_from_stream ?max_size ~boundary ~create ~add ~stop s = Ocsigen_stream.next s >>= fun s -> read_multipart_body ~boundary ~decode_part s >>= fun _ -> Lwt.return ()) (function - | Ocsigen_stream.Stream_too_small -> - Lwt.fail Ocsigen_lib.Ocsigen_Bad_Request - | e -> Lwt.fail e) + | Ocsigen_stream.Stream_too_small -> + Lwt.fail Ocsigen_lib.Ocsigen_Bad_Request + | e -> Lwt.fail e) let get_boundary ctparams = List.assoc "boundary" ctparams @@ -280,9 +286,9 @@ let post_params_form_urlencoded body_gen _ _ = in Lwt.return (l, [])) (function - | Ocsigen_stream.String_too_large -> - Lwt.fail Ocsigen_lib.Input_is_too_large - | e -> Lwt.fail e) + | Ocsigen_stream.String_too_large -> + Lwt.fail Ocsigen_lib.Input_is_too_large + | e -> Lwt.fail e) let post_params_multipart_form_data ctparams body_gen upload_dir max_size = (* Same question here, should this stream be consumed after an diff --git a/src/server/ocsigen_parseconfig.ml b/src/server/ocsigen_parseconfig.ml index ec1dbb97e..77391d872 100644 --- a/src/server/ocsigen_parseconfig.ml +++ b/src/server/ocsigen_parseconfig.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (******************************************************************) (** Config file parsing *) @@ -245,7 +245,12 @@ let get_defaulthostname ~defaulthostname ~host = raise (Ocsigen_config.Config_file_error ("Incorrect hostname " ^ host)) let later_pass_host_attr - (name, charset, defaulthostname, defaulthttpport, defaulthttpsport, ishttps) + ( name + , charset + , defaulthostname + , defaulthttpport + , defaulthttpsport + , ishttps ) = function | "hostfilter", s -> ( match name with diff --git a/src/server/ocsigen_parseconfig.mli b/src/server/ocsigen_parseconfig.mli index c0195f25a..1b91e024e 100644 --- a/src/server/ocsigen_parseconfig.mli +++ b/src/server/ocsigen_parseconfig.mli @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) (** Config file parsing. See also module {! Ocsigen_extensions.​Configuration } *) diff --git a/src/server/ocsigen_request.ml b/src/server/ocsigen_request.ml index a66c3c670..0f0038319 100644 --- a/src/server/ocsigen_request.ml +++ b/src/server/ocsigen_request.ml @@ -71,9 +71,20 @@ type t = ; r_connection_closed : unit Lwt.t ; r_timeofday : float } -let make ?(forward_ip = []) ?sub_path ?original_full_path - ?(request_cache = Polytables.create ()) ?cookies_override ~address ~port - ~ssl ~filenames ~sockaddr ~body ~connection_closed request +let make + ?(forward_ip = []) + ?sub_path + ?original_full_path + ?(request_cache = Polytables.create ()) + ?cookies_override + ~address + ~port + ~ssl + ~filenames + ~sockaddr + ~body + ~connection_closed + request = let r_remote_ip = lazy @@ -107,19 +118,28 @@ let make ?(forward_ip = []) ?sub_path ?original_full_path let path_string {r_uri = {u_path_string; _}; _} = Lazy.force u_path_string let path {r_uri = {u_path; _}; _} = Lazy.force u_path -let update ?ssl ?forward_ip ?remote_ip ?sub_path ?meth ?get_params_flat - ?post_data ?cookies_override ?(full_rewrite = false) ?uri - ({ r_ssl - ; r_uri = {u_uri; _} as r_uri - ; r_meth - ; r_forward_ip - ; r_remote_ip - ; r_remote_ip_parsed - ; r_cookies_override - ; r_body - ; r_sub_path - ; r_original_full_path - ; _ } as r) +let update + ?ssl + ?forward_ip + ?remote_ip + ?sub_path + ?meth + ?get_params_flat + ?post_data + ?cookies_override + ?(full_rewrite = false) + ?uri + ({ r_ssl + ; r_uri = {u_uri; _} as r_uri + ; r_meth + ; r_forward_ip + ; r_remote_ip + ; r_remote_ip_parsed + ; r_cookies_override + ; r_body + ; r_sub_path + ; r_original_full_path + ; _ } as r) = let r_ssl = match ssl with Some ssl -> ssl | None -> r_ssl and r_forward_ip = diff --git a/src/server/ocsigen_response.ml b/src/server/ocsigen_response.ml index c95f6edba..462fdf8ce 100644 --- a/src/server/ocsigen_response.ml +++ b/src/server/ocsigen_response.ml @@ -3,8 +3,10 @@ type t = ; a_body : Cohttp_lwt.Body.t ; a_cookies : Ocsigen_cookie_map.t } -let make ?(body = Cohttp_lwt.Body.empty) ?(cookies = Ocsigen_cookie_map.empty) - a_response +let make + ?(body = Cohttp_lwt.Body.empty) + ?(cookies = Ocsigen_cookie_map.empty) + a_response = {a_response; a_body = body; a_cookies = cookies} @@ -48,7 +50,9 @@ let header_multi {a_response; _} id = Cohttp.Header.get_multi h (Ocsigen_header.Name.to_string id) let add_header - ({a_response = {Cohttp.Response.headers; _} as a_response; _} as a) id v + ({a_response = {Cohttp.Response.headers; _} as a_response; _} as a) + id + v = { a with a_response = @@ -57,7 +61,9 @@ let add_header Cohttp.Header.add headers (Ocsigen_header.Name.to_string id) v } } let add_header_multi - ({a_response = {Cohttp.Response.headers; _} as a_response; _} as a) id l + ({a_response = {Cohttp.Response.headers; _} as a_response; _} as a) + id + l = let id = Ocsigen_header.Name.to_string id in let headers = @@ -66,7 +72,9 @@ let add_header_multi {a with a_response = {a_response with Cohttp.Response.headers}} let replace_header - ({a_response = {Cohttp.Response.headers; _} as a_response; _} as a) id v + ({a_response = {Cohttp.Response.headers; _} as a_response; _} as a) + id + v = { a with a_response = diff --git a/src/server/ocsigen_server.ml b/src/server/ocsigen_server.ml index 128743622..b174b734d 100644 --- a/src/server/ocsigen_server.ml +++ b/src/server/ocsigen_server.ml @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) open Lwt.Infix @@ -130,11 +130,23 @@ type instruction = let default_re_string = ".*" -let host ?(regexp = default_re_string) ?port ?default_hostname ?default_httpport - ?default_httpsport ?default_protocol_is_https ?mime_assoc ?charset_assoc - ?default_directory_index ?list_directory_content ?follow_symlinks - ?do_not_serve_404 ?do_not_serve_403 ?uploaddir ?maxuploadfilesize - instructions +let host + ?(regexp = default_re_string) + ?port + ?default_hostname + ?default_httpport + ?default_httpsport + ?default_protocol_is_https + ?mime_assoc + ?charset_assoc + ?default_directory_index + ?list_directory_content + ?follow_symlinks + ?do_not_serve_404 + ?do_not_serve_403 + ?uploaddir + ?maxuploadfilesize + instructions = let def = Ocsigen_extensions.default_config_info () in let default default o = Option.value o ~default in @@ -304,13 +316,13 @@ let main config = in Ocsigen_command.get_command_function () ?prefix s c) (function - | Ocsigen_command.Unknown_command -> - Lwt_log.ign_warning ~section "Unknown command"; - Lwt.return () - | e -> - Lwt_log.ign_error ~section ~exn:e - "Uncaught Exception after command"; - Lwt.fail e) + | Ocsigen_command.Unknown_command -> + Lwt_log.ign_warning ~section "Unknown command"; + Lwt.return () + | e -> + Lwt_log.ign_error ~section ~exn:e + "Uncaught Exception after command"; + Lwt.fail e) >>= f in ignore (f ())); @@ -401,14 +413,43 @@ let exec config = Lwt_log.ign_warning ~section "Multiple servers not supported anymore" (* Multiple servers not supported any more *) -let start ?(ports = [`All, 8080]) ?ssl_ports ?ssl_info ?default_charset ?logdir - ?datadir ?uploaddir ?maxuploadfilesize ?syslog_facility ?configfile - ?usedefaulthostname ?pidfile ?mimefile ?verbose ?veryverbose ?silent ?daemon - ?debug ?debugmode ?minthreads ?maxthreads ?max_number_of_threads_queued - ?max_number_of_connections ?client_timeout ?server_timeout ?shutdown_timeout - ?filebuffersize ?maxrequestbodysize ?maxrequestbodysizeinmemory ?bindir - ?extdir ?command_pipe ?disablepartialrequests ?respect_pipeline ?maxretries - instructions +let start + ?(ports = [`All, 8080]) + ?ssl_ports + ?ssl_info + ?default_charset + ?logdir + ?datadir + ?uploaddir + ?maxuploadfilesize + ?syslog_facility + ?configfile + ?usedefaulthostname + ?pidfile + ?mimefile + ?verbose + ?veryverbose + ?silent + ?daemon + ?debug + ?debugmode + ?minthreads + ?maxthreads + ?max_number_of_threads_queued + ?max_number_of_connections + ?client_timeout + ?server_timeout + ?shutdown_timeout + ?filebuffersize + ?maxrequestbodysize + ?maxrequestbodysizeinmemory + ?bindir + ?extdir + ?command_pipe + ?disablepartialrequests + ?respect_pipeline + ?maxretries + instructions = Ocsigen_config.set_ports ports; Option.iter Ocsigen_config.set_ssl_ports ssl_ports; diff --git a/src/server/ocsigen_server.mli b/src/server/ocsigen_server.mli index 91562afd0..e4b0b7afb 100644 --- a/src/server/ocsigen_server.mli +++ b/src/server/ocsigen_server.mli @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *) +*) val section : Lwt_log_core.section (** use Lwt_log.Section.set_level in order to debug *)