diff -Nru ocsigenserver-2.2.0/boring ocsigenserver-2.4.0/boring --- ocsigenserver-2.2.0/boring 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/boring 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -\.cmi$ -\.cmx$ -\.cmo$ -\.cma$ -\.cmxa$ -\.cmxs$ -\.o$ -\.a$ -\.annot$ -~$ -^Makefile.config$ -^src/baselib/ocsigen_config.ml$ -^src/http/http_lexer.ml$ -^src/http/http_parser.ml$ -^src/http/http_parser.mli$ -^src/server/ocsigenserver$ -^src/server/ocsigenserver.opt$ -^src/extensions/ocsipersist.mli$ -^src/extensions/ocsipersist-dbm/ocsidbm$ -^src/extensions/ocsipersist-dbm/ocsidbm.opt$ -^src/extensions/ocsipersist-dbm/ocsipersist.mli$ -^src/files/META$ -^src/files/META.ocsigenserver$ -^src/extensions/files/META$ -^src/extensions/files/META.ocsigenserver_ext$ -^ocsigenserver.conf(|.opt).sample$ -^local/var/log/(access|errors|warnings).log$ -^local/var/lib/ocsidb$ -^local/etc/ocsigenserver.conf(|.opt)$ -^doc/api-html \ No newline at end of file diff -Nru ocsigenserver-2.2.0/configure ocsigenserver-2.4.0/configure --- ocsigenserver-2.2.0/configure 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/configure 2014-04-16 16:01:15.000000000 +0000 @@ -414,6 +414,8 @@ check_library netstring \ "See ocamlnet: http://projects.camlcity.org/projects/ocamlnet.html" +check_library netstring-pcre \ + "See ocamlnet: http://projects.camlcity.org/projects/ocamlnet.html" check_library netsys \ "See ocamlnet: http://projects.camlcity.org/projects/ocamlnet.html" diff -Nru ocsigenserver-2.2.0/debian/changelog ocsigenserver-2.4.0/debian/changelog --- ocsigenserver-2.2.0/debian/changelog 2013-12-07 08:35:12.000000000 +0000 +++ ocsigenserver-2.4.0/debian/changelog 2014-06-26 09:28:46.000000000 +0000 @@ -1,3 +1,16 @@ +ocsigenserver (2.4.0-1) unstable; urgency=medium + + * New upstream release + * Update debian/watch + + -- Stéphane Glondu Thu, 26 Jun 2014 11:27:56 +0200 + +ocsigenserver (2.3.0-1) unstable; urgency=medium + + * New upstream release + + -- Stéphane Glondu Mon, 02 Jun 2014 07:45:09 +0200 + ocsigenserver (2.2.0-3) unstable; urgency=low * Upload to unstable (Closes: #724168) diff -Nru ocsigenserver-2.2.0/debian/control ocsigenserver-2.4.0/debian/control --- ocsigenserver-2.2.0/debian/control 2013-11-10 15:47:46.000000000 +0000 +++ ocsigenserver-2.4.0/debian/control 2014-06-26 09:26:02.000000000 +0000 @@ -19,6 +19,7 @@ libzip-ocaml-dev (>= 1.04-6~), libcryptokit-ocaml-dev (>= 1.3-14~), libtyxml-ocaml-dev (>= 2.2.0), + libipaddr-ocaml-dev, dh-ocaml (>= 0.9.5~) Standards-Version: 3.9.4 Homepage: http://ocsigen.org/ocsigenserver/ diff -Nru ocsigenserver-2.2.0/debian/patches/0001-Fix-compilation-with-ocamlnet-3.6.5.patch ocsigenserver-2.4.0/debian/patches/0001-Fix-compilation-with-ocamlnet-3.6.5.patch --- ocsigenserver-2.2.0/debian/patches/0001-Fix-compilation-with-ocamlnet-3.6.5.patch 2013-11-10 12:22:46.000000000 +0000 +++ ocsigenserver-2.4.0/debian/patches/0001-Fix-compilation-with-ocamlnet-3.6.5.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -From: Stephane Glondu -Date: Thu, 6 Jun 2013 11:46:46 +0200 -Subject: Fix compilation with ocamlnet 3.6.5 - ---- - src/extensions/Makefile | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/extensions/Makefile b/src/extensions/Makefile -index e7a0fad..6caeb92 100644 ---- a/src/extensions/Makefile -+++ b/src/extensions/Makefile -@@ -4,6 +4,7 @@ PACKAGE := lwt.unix \ - lwt.ssl \ - lwt.react \ - netstring \ -+ netstring-pcre \ - tyxml.parser \ - - LIBS := -I ../baselib -I ../http -I ../server ${addprefix -package ,${PACKAGE}} --- diff -Nru ocsigenserver-2.2.0/debian/patches/series ocsigenserver-2.4.0/debian/patches/series --- ocsigenserver-2.2.0/debian/patches/series 2013-11-10 12:22:46.000000000 +0000 +++ ocsigenserver-2.4.0/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -0001-Fix-compilation-with-ocamlnet-3.6.5.patch diff -Nru ocsigenserver-2.2.0/debian/watch ocsigenserver-2.4.0/debian/watch --- ocsigenserver-2.2.0/debian/watch 2013-11-10 12:22:46.000000000 +0000 +++ ocsigenserver-2.4.0/debian/watch 2014-06-19 11:13:09.000000000 +0000 @@ -1,3 +1,2 @@ version=3 -opts="uversionmangle=s/-rc/~rc/,dversionmangle=s/\+dfsg\d*$//" \ -http://ocsigen.org/download/ocsigenserver-(.*)\.tar\.gz +http://ocsigen.org/ocsigenserver/install .*/archive/(.*)\.tar\.gz diff -Nru ocsigenserver-2.2.0/doc/indexdoc ocsigenserver-2.4.0/doc/indexdoc --- ocsigenserver-2.2.0/doc/indexdoc 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/indexdoc 2014-04-16 16:01:15.000000000 +0000 @@ -11,7 +11,7 @@ Ocsigen_config } -{2 Extending Ocsigen} +{2 Extending Ocsigen Server} {!modules: Ocsigen_extensions Ocsigen_local_files diff -Nru ocsigenserver-2.2.0/doc/Makefile ocsigenserver-2.4.0/doc/Makefile --- ocsigenserver-2.2.0/doc/Makefile 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/Makefile 2014-04-16 16:01:15.000000000 +0000 @@ -4,7 +4,7 @@ OCAMLDOC := ${OCAMLFIND} ocamldoc ODOC_WIKI := odoc_wiki.cma -LIBS := -package lwt,tyxml,ssl \ +LIBS := -package lwt,tyxml,ssl,netstring-pcre,ipaddr \ ${addprefix -I ../src/, baselib http server extensions } doc: api-html/index.html diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/accesscontrol.wiki ocsigenserver-2.4.0/doc/manual-wiki/accesscontrol.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/accesscontrol.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/accesscontrol.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -1,6 +1,6 @@ =Accesscontrol= -Accesscontrol is in beta version. Submit your bugs and feature wishes [[site:trac/|here]]. +Accesscontrol is in beta version. Submit your bugs and feature wishes [[https://github.com/ocsigen/ocsigenserver|here]]. = The accesscontrol extension = diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/cgimod.wiki ocsigenserver-2.4.0/doc/manual-wiki/cgimod.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/cgimod.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/cgimod.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -1,6 +1,6 @@ =CGImod= -CGImod is a module for running CGI scripts with ocsigen. It is in beta version. Submit your bugs, feature wishes (or any enhancement/mistake in the documentation) [[site:trac/|here]]. +CGImod is a module for running CGI scripts with ocsigen. It is in beta version. Submit your bugs, feature wishes (or any enhancement/mistake in the documentation) [[https://github.com/ocsigen/ocsigenserver|here]]. == CGImod == @@ -11,7 +11,7 @@ on your server. It is also the only way to run PHP scripts on Ocsigen, through php5-cgi. -===What do I need to use cgimod? +===What do I need to use cgimod? You need a working Ocsigen installation. If you want to run PHP scripts, you need php5-cgi too. @@ -51,7 +51,7 @@ {{{ - + }}} @@ -64,9 +64,9 @@ {{{ - + }}} @@ -81,9 +81,9 @@ Here is another example: {{{ - + }}} @@ -91,23 +91,23 @@ interface for darcs, written in Python. + The exec way: useful for PHP (and other script languages) - + {{{ - - }}} @@ -125,12 +125,12 @@ - - - - + + + }}} diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/config.wiki ocsigenserver-2.4.0/doc/manual-wiki/config.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/config.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/config.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -283,6 +283,18 @@ {{{ /var/lib/ocsigenserver }}} + +===={{{}}} : log to syslog + +Specifies which syslog facility to use, instead of logging to files. This option +is mutually exclusive with . + +Example: + +{{{ +Local7 +}}} + ===={{{}}} and {{{}}} : user who runs the server @@ -614,12 +626,12 @@ -It is also possible to set the default ports for http and https using {{{defaulthttpport}}} and {{{defaulthttpsport}}}. These arguments may be used by extensions (like Eliom) if they need to create absolute links. Example: +It is also possible to set the default ports for http and https, and default protocol using {{{defaulthttpport}}}, {{{defaulthttpsport}}} and {{{defaultprotocol=}}}. These arguments may be used by extensions (like Eliom) if they need to create absolute links. Example: {{{ - ... + ... }}} Inside {{{}}}, write the configuration for your main (root) site. These options depend on the extensions loaded. See the documentation about the extensions to know what to put here. It is also possible to define here several subsites, using {{{}}} (see below). @@ -683,5 +695,3 @@ In that case, the server will wait for all the connections to terminate, even if it takes a lot of time. The default timeout value can be set in the configuration file (see {{{shutdowntimeout}}} option above). - - diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/cors.wiki ocsigenserver-2.4.0/doc/manual-wiki/cors.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/cors.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/cors.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -3,7 +3,7 @@ = The CORS extension = This extension is used to allow other servers to serve pages -requesting datas on that one using XmlHttpReauest. It adds headers to +requesting data on that one using XmlHttpRequest. It adds headers to the server response and handle preflight OPTIONS requests to indicate if some client side code has the right to access resources. diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/deflatemod.wiki ocsigenserver-2.4.0/doc/manual-wiki/deflatemod.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/deflatemod.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/deflatemod.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -1,21 +1,21 @@ =Deflatemod= -Deflatemod is in beta version. Submit your bugs and feature wishes [[http://ocsigen.org/trac|here]]. +Deflatemod is in beta version. Submit your bugs and feature wishes [[https://github.com/ocsigen/ocsigenserver|here]]. == Usage == -=== What is deflatemod? +=== What is deflatemod? Deflatemod is a module for Ocsigen that allows you to deflate content, using HTTP/1.1 mechanism. It supports gzip as well as deflate. -=== What do I need to use deflatemod? +=== What do I need to use deflatemod? You need the camlzip library by Xavier Leroy and a working Ocsigen -installation. +installation. -=== How do I use deflatemod? +=== How do I use deflatemod? First, load the extension in the configuration file: @@ -40,7 +40,7 @@ }}} -=== How do I configure deflatemod? +=== How do I configure deflatemod? Again, the options are in ocsigen.conf. You can set a few options globally, in the extension tag: @@ -50,7 +50,7 @@ * the buffer size: default is 1024. You shouldn't need to change this one, but you can still try a few other values (any feedback welcomed). -For example: +For example: {{{ @@ -61,14 +61,14 @@ Next, you '''have to''' specify which pages you whish to deflate, in which host/site (otherwise, deflatemod won't compress anything). See next question to do that. -=== I want to deflate only some files. Is it possible? +=== I want to deflate only some files. Is it possible? To some extent, yes. You can '''exclude''' some files and deflate every other, according to their mime-type or extension (''ie.'' the end of the '''url''' in fact, not really the file name on the disk). Here is an example: {{{ - + @@ -87,7 +87,7 @@ on their mime-types or extension: {{{ - + diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/outputfilter.wiki ocsigenserver-2.4.0/doc/manual-wiki/outputfilter.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/outputfilter.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/outputfilter.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -1,6 +1,6 @@ =Outputfilter= -Outputfilter allows to filter the output and rewrite some part of it (for example headers) before sending it to the client. It is in beta version. Submit your bugs, feature wishes (or any enhancement/mistake in the documentation) [[site:trac|here]]. +Outputfilter allows to filter the output and rewrite some part of it (for example headers) before sending it to the client. It is in beta version. Submit your bugs, feature wishes (or any enhancement/mistake in the documentation) [[https://github.com/ocsigen/ocsigenserver|here]]. For now it only allows to rewrite HTTP or add headers. diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/quickstart.wiki ocsigenserver-2.4.0/doc/manual-wiki/quickstart.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/quickstart.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/quickstart.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -90,5 +90,4 @@ to our mailing list]] and ask your question here. If you find a bug, a mistake in the documentation (even a small one), -or if you want to make a suggestion, [[site:trac|register to our bug -tracking system]] and fill a ticket. +or if you want to make a suggestion, [[https://github.com/ocsigen/ocsigenserver|fill a ticket on Github]]. diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/redirectmod.wiki ocsigenserver-2.4.0/doc/manual-wiki/redirectmod.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/redirectmod.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/redirectmod.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -1,6 +1,6 @@ =Redirectmod= -Redirectmod is a module allowing to define HTTP redirections from Ocsigen's configuration file. Submit your bugs and feature wishes (or any enhancement/mistake in the documentation) [[site:trac|here]]. +Redirectmod is a module allowing to define HTTP redirections from Ocsigen's configuration file. Submit your bugs and feature wishes (or any enhancement/mistake in the documentation) [[https://github.com/ocsigen/ocsigenserver|here]]. To use that extension, first load it from the configuration file: {{{ diff -Nru ocsigenserver-2.2.0/doc/manual-wiki/rewritemod.wiki ocsigenserver-2.4.0/doc/manual-wiki/rewritemod.wiki --- ocsigenserver-2.2.0/doc/manual-wiki/rewritemod.wiki 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/doc/manual-wiki/rewritemod.wiki 2014-04-16 16:01:15.000000000 +0000 @@ -1,6 +1,6 @@ =Rewritemod= -Rewritemod allows to rewrite the requests.It is available from Ocsigen version 1.2. It is really basic for now, but for most uses you don't need it, as staticmod and others already have sophisticated configuration features. It is in beta version. Submit your bugs and feature wishes [[site:trac|here]]. +Rewritemod allows to rewrite the requests.It is available from Ocsigen version 1.2. It is really basic for now, but for most uses you don't need it, as staticmod and others already have sophisticated configuration features. It is in beta version. Submit your bugs and feature wishes [[https://github.com/ocsigen/ocsigenserver|here]]. To use that extension, first load it from the configuration file: {{{ diff -Nru ocsigenserver-2.2.0/format.sh ocsigenserver-2.4.0/format.sh --- ocsigenserver-2.2.0/format.sh 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/format.sh 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "# Removing tabs" +find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*.ml[il]?" -exec sed -i 's/ //g' {} \; +echo "# Indent files" +find ./ -regex "^\.\(/[a-zA-Z0-9_-.]*\)*.ml[il]?" -exec ocp-indent -i {} \; diff -Nru ocsigenserver-2.2.0/.gitignore ocsigenserver-2.4.0/.gitignore --- ocsigenserver-2.2.0/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/.gitignore 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1,34 @@ +*.cmi +*.cmx +*.cmo +*.cma +*.cmxa +*.cmxs +*.o +*.a +*.annot +*~ +Makefile.config +src/baselib/ocsigen_config.ml +src/http/http_lexer.ml +src/http/http_parser.ml +src/http/http_parser.mli +src/server/ocsigenserver +src/server/ocsigenserver.opt +src/extensions/ocsipersist.mli +src/extensions/ocsipersist-dbm/ocsidbm +src/extensions/ocsipersist-dbm/ocsidbm.opt +src/extensions/ocsipersist-dbm/ocsipersist.mli +src/files/META +src/files/META.ocsigenserver +src/extensions/files/META +src/extensions/files/META.ocsigenserver_ext +ocsigenserver.conf.sample +ocsigenserver.conf.opt.sample +local/var/log/access.log +local/var/log/errors.log +local/var/log/warnings.log +local/var/lib/ocsidb +local/etc/ocsigenserver.conf +local/etc/ocsigenserver.conf.opt +doc/api-html diff -Nru ocsigenserver-2.2.0/Makefile ocsigenserver-2.4.0/Makefile --- ocsigenserver-2.2.0/Makefile 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/Makefile 2014-04-16 16:01:15.000000000 +0000 @@ -21,10 +21,10 @@ .PHONY: run.local run.opt.local top run.local: byte - CAML_LD_LIBRARY_PATH=src/server src/server/${PROJECTNAME} -c local/etc/${PROJECTNAME}.conf + CAML_LD_LIBRARY_PATH=src/server:$(CAML_LD_LIBRARY_PATH) src/server/${PROJECTNAME} -c local/etc/${PROJECTNAME}.conf run.opt.local: opt - CAML_LD_LIBRARY_PATH=src/server src/server/${PROJECTNAME}.opt -c local/etc/${PROJECTNAME}.conf + CAML_LD_LIBRARY_PATH=src/server:$(CAML_LD_LIBRARY_PATH) src/server/${PROJECTNAME}.opt -c local/etc/${PROJECTNAME}.conf top: cd src/server && ${MAKE} top diff -Nru ocsigenserver-2.2.0/Makefile.dist ocsigenserver-2.4.0/Makefile.dist --- ocsigenserver-2.2.0/Makefile.dist 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/Makefile.dist 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1,41 @@ + +## +## Usage: +## +## If the released version is tagged in the main repository, use: +## +## make -f Makefile.dist +## +## If the tag has not been pushed, use: +## +## make -f Makefile.dist REPO=${PWD} +## +## otherwise, use: +## +## make -f Makefile.dist REPO=${PWD} VERSION=master +## + +#VERSION?=$(shell grep Version: _oasis | cut -d ' ' -f 2) +VERSION=$(shell cat VERSION) +REPO?=https://github.com/ocsigen/ocsigenserver + +all: dist sign + +dist: + @rm -rf ocsigenserver-${VERSION} \ + ocsigenserver-${VERSION}.tar.gz \ + ocsigenserver-${VERSION}.tar.gz.asc + git clone --local -b ${VERSION} ${REPO} ocsigenserver-${VERSION} +# oasis -C ocsigenserver-${VERSION} setup +# sed -i "s/SETUP := setup-dev.exe/SETUP := setup.exe/" \ +# ocsigenserver-${VERSION}/Makefile + cd ocsigenserver-${VERSION} && rm -rf .git .gitignore Makefile.dist + tar cvzf ocsigenserver-${VERSION}.tar.gz ocsigenserver-${VERSION} + @rm -rf ocsigenserver-${VERSION} + +sign: ocsigenserver-${VERSION}.tar.gz.asc + +ocsigenserver-${VERSION}.tar.gz.asc: ocsigenserver-${VERSION}.tar.gz + gpg --armor -b $^ + +.PHONY: dist sign diff -Nru ocsigenserver-2.2.0/Makefile.options ocsigenserver-2.4.0/Makefile.options --- ocsigenserver-2.2.0/Makefile.options 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/Makefile.options 2014-04-16 16:01:15.000000000 +0000 @@ -29,11 +29,13 @@ LWT_EXTRA_PACKAGE:=lwt.extra endif -BASE_PACKAGE := lwt +BASE_PACKAGE := lwt ipaddr SERVER_PACKAGE := lwt.ssl \ ${LWT_EXTRA_PACKAGE} \ + ipaddr \ netstring \ + netstring-pcre \ findlib \ cryptokit \ tyxml \ @@ -50,4 +52,3 @@ \"${PROJECTNAME}.baselib\"; \ \"${PROJECTNAME}.http\"; \ \"${PROJECTNAME}\"; \ - diff -Nru ocsigenserver-2.2.0/.ocp-indent ocsigenserver-2.4.0/.ocp-indent --- ocsigenserver-2.2.0/.ocp-indent 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/.ocp-indent 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1,3 @@ +normal +with=0 +syntax=lwt mll diff -Nru ocsigenserver-2.2.0/opam/descr ocsigenserver-2.4.0/opam/descr --- ocsigenserver-2.2.0/opam/descr 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/opam/descr 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1,6 @@ +A full-featured and extensible Web server +It implements most features of the HTTP protocol, and has a very +powerful extension mechanism that make very easy to plug your own +OCaml modules for generating pages. Many extensions are already +written, like a reverse proxy, content compression, access control, +authentication, etc. diff -Nru ocsigenserver-2.2.0/opam/files/ocsigenserver.install ocsigenserver-2.4.0/opam/files/ocsigenserver.install --- ocsigenserver-2.2.0/opam/files/ocsigenserver.install 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/opam/files/ocsigenserver.install 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1,4 @@ +bin: [ + "src/server/ocsigenserver" + "src/server/ocsigenserver.opt" +] diff -Nru ocsigenserver-2.2.0/opam/opam ocsigenserver-2.4.0/opam/opam --- ocsigenserver-2.2.0/opam/opam 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/opam/opam 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1,30 @@ +opam-version: "1" +maintainer: "dev@ocsigen.org" +build: [ + ["sh" "configure" "--prefix" "%{prefix}%" "--ocsigen-user" "%{user}%" "--ocsigen-group" "%{group}%" "--commandpipe" "%{lib}%/ocsigenserver/var/run/ocsigenserver_command" "--logdir" "%{lib}%/ocsigenserver/var/log/ocsigenserver" "--mandir" "%{man}%/man1" "--docdir" "%{lib}%/ocsigenserver/share/doc/ocsigenserver" "--commandpipe" "%{lib}%/ocsigenserver/var/run/ocsigenserver_command" "--staticpagesdir" "%{lib}%/ocsigenserver/var/www" "--datadir" "%{lib}%/ocsigenserver/var/lib/ocsigenserver" "--sysconfdir" "%{lib}%/ocsigenserver/etc/ocsigenserver"] + [make] + [make "install"] +] +remove: [ + ["rm" "-rf" "%{lib}%/ocsigenserver"] +] +depends: [ + "ocamlfind" + "base-unix" + "base-threads" + "react" + "ssl" + "lwt" + "ocamlnet" {>= "3.6.0"} + "pcre-ocaml" + "cryptokit" + "tyxml" {>= "9999"} + ("dbm" | "sqlite3-ocaml") + "ipaddr" {>= "2.1"} +] +depopts: [ + "camlzip" +] +conflicts: [ + "camlzip" {< "1.04"} +] diff -Nru ocsigenserver-2.2.0/opam/url ocsigenserver-2.4.0/opam/url --- ocsigenserver-2.2.0/opam/url 1970-01-01 00:00:00.000000000 +0000 +++ ocsigenserver-2.4.0/opam/url 2014-04-16 16:01:15.000000000 +0000 @@ -0,0 +1 @@ +git: "https://github.com/ocsigen/ocsigenserver.git" diff -Nru ocsigenserver-2.2.0/README ocsigenserver-2.4.0/README --- ocsigenserver-2.2.0/README 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/README 2014-04-16 16:01:15.000000000 +0000 @@ -15,15 +15,17 @@ * findlib * react (tested with 0.9.3) * ocamlssl (tested with 0.4.6) - * lwt (need version >= 2.4.2, with react and ssl support) - * ocamlnet (tested with 3.6, with netstring and netsys) + * lwt (need version >= 2.4.2, with react and ssl support) + * ocamlnet (tested with 3.6, with netstring, netstring-pcre and netsys) * pcre-ocaml (tested with 6.2.5) * cryptokit (tested with 1.6) * ocaml-text (tested with 0.6) - * tyxml (need version 2.2) + * tyxml (need version 3) + * ipaddr (need version >= 2.1) * ocamlsqlite3 (tested with 2.0.2) OR * dbm (tested with 1.0) + Optional libraries: * camlzip (tested with 1.04) @@ -90,23 +92,23 @@ Vincent Balat (project leader, Web server, Ocsigenmod, Eliom, Eliom client, Staticmod, XHTML syntax extension, documentation, Ocsimore, extension mechanism, Ocsidbm, Ocsipersist with DBM, ...) -Jérôme Vouillon +Jérôme Vouillon (Lwt, Web server, js_of_ocaml, O'Closure, ...) Boris Yakobowski (Ocsimore, module Extendconfiguration, Ocsigen server...) Benjamin Canou (O'Browser) -Jérémie Dimino +Jérémie Dimino (Lwt) -Raphaël Proust +Raphaël Proust (Ocsforge, Eliom client, Comet) -Stéphane Glondu +Stéphane Glondu (Configuration file, Findlib integration, access control, HTTP authentication, Debian package, ...) Gabriel Kerneis (XHTML syntax extension for OCaml 3.10, Ocsipersist with SQLite, CGI module, forms in Eliom, deflatemod, ...) Denis Berthod (HTTP protocol, Web server) -Grégoire Henry +Grégoire Henry (safe unmarshalling of client data) Pierre Chambart (Comet) @@ -130,11 +132,11 @@ (Web server, HTTPS) Archibald Pontier (Atom, Pubsubhubbub) -Jérôme Velleine +Jérôme Velleine (CGI module) Charles Oran (O'Closure) Pierre Clairambault (Lwt_lib, Gentoo package, configure script, ...) -Cécile Herbelin +Cécile Herbelin (HTML5, Benchmarks) diff -Nru ocsigenserver-2.2.0/src/baselib/Makefile ocsigenserver-2.4.0/src/baselib/Makefile --- ocsigenserver-2.2.0/src/baselib/Makefile 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/Makefile 2014-04-16 16:01:15.000000000 +0000 @@ -1,6 +1,6 @@ include ../../Makefile.config -LIBS := -package lwt.unix,netstring,cryptokit,findlib,tyxml,lwt.syntax,${LWT_EXTRA_PACKAGE} +LIBS := -package lwt.unix,netstring,netstring-pcre,cryptokit,findlib,tyxml,lwt.syntax,${LWT_EXTRA_PACKAGE},ipaddr OCAMLC := $(OCAMLFIND) ocamlc${BYTEDBG} ${THREAD} OCAMLOPT := $(OCAMLFIND) ocamlopt ${OPTDBG} ${THREAD} OCAMLDOC := $(OCAMLFIND) ocamldoc diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_cache.mli ocsigenserver-2.4.0/src/baselib/ocsigen_cache.mli --- ocsigenserver-2.2.0/src/baselib/ocsigen_cache.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_cache.mli 2014-04-16 16:01:15.000000000 +0000 @@ -76,14 +76,18 @@ -(** Doubly-linked lists with maximum number of entries and limited lifespan for - entries. *) +(** Doubly-linked lists with maximum number of entries, + and (possibly) limited lifespan for entries. *) module Dlist : sig type 'a t type 'a node + + (** Create a dlist. It takes the maximum length of the list as + parameter. The optional [?timer] parameter sets a maximum + lifetime for elements (in seconds). *) val create : ?timer:float -> int -> 'a t - (** Adds an element to the list, + (** Adds an element to the list, and possibly returns the element that has been removed if the maximum size was exceeded. *) val add : 'a -> 'a t -> 'a option @@ -91,12 +95,12 @@ (** Removes an element from its list. If it is not in a list, it does nothing. If it is in a list, it calls the finaliser, then removes the element. - If the finaliser fails with an exception, + If the finaliser fails with an exception, the element is removed and the exception is raised again. *) val remove : 'a node -> unit - (** Removes the element from its list without finalising, + (** Removes the element from its list without finalising, then adds it as newest. *) val up : 'a node -> unit diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_config.mli ocsigenserver-2.4.0/src/baselib/ocsigen_config.mli --- ocsigenserver-2.2.0/src/baselib/ocsigen_config.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_config.mli 2014-04-16 16:01:15.000000000 +0000 @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(** Configuring Ocsigen server *) + open Ocsigen_lib exception Config_file_error of string @@ -29,6 +31,7 @@ val builtin_packages : String.Set.t val set_logdir : string -> unit +val set_syslog_facility: Lwt_log.syslog_facility option -> unit val set_configfile : string -> unit val set_pidfile : string -> unit val set_mimefile : string -> unit @@ -65,6 +68,7 @@ val set_shutdown_timeout : float option -> unit val get_logdir : unit -> string +val get_syslog_facility: unit -> Lwt_log.syslog_facility option val get_config_file : unit -> string val get_pidfile : unit -> string option val get_mimefile : unit -> string diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_config.ml.in ocsigenserver-2.4.0/src/baselib/ocsigen_config.ml.in --- ocsigenserver-2.2.0/src/baselib/ocsigen_config.ml.in 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_config.ml.in 2014-04-16 16:01:15.000000000 +0000 @@ -48,7 +48,8 @@ (* Server config: *) let (uploaddir : string option ref) = ref None -let logdir = ref "_LOGDIR_" +let logdir = ref (Some ("_LOGDIR_")) +let syslog_facility = ref None let default_user = ref "_OCSIGENUSER_" let default_group = ref "_OCSIGENGROUP_" let minthreads = ref 10 @@ -81,7 +82,8 @@ let shutdowntimeout = ref (Some 10.) let set_uploaddir u = uploaddir := u -let set_logdir s = logdir := s +let set_logdir s = logdir := Some s +let set_syslog_facility f = syslog_facility := f; logdir := None let set_configfile s = config_file := s let set_pidfile s = pidfile := Some s let set_mimefile s = mimefile := s @@ -120,7 +122,12 @@ let set_shutdown_timeout s = shutdowntimeout := s let get_uploaddir () = !uploaddir -let get_logdir () = !logdir +let get_logdir () = + match !logdir with + | Some s -> s + | None -> raise ( + Config_file_error ("Log directory requested, but not set"));; +let get_syslog_facility () = !syslog_facility let get_config_file () = !config_file let get_pidfile () = !pidfile let get_mimefile () = !mimefile diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_lib_base.ml ocsigenserver-2.4.0/src/baselib/ocsigen_lib_base.ml --- ocsigenserver-2.2.0/src/baselib/ocsigen_lib_base.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_lib_base.ml 2014-04-16 16:01:15.000000000 +0000 @@ -57,6 +57,9 @@ let get f = function | Some x -> x | None -> f () + let get' a = function + | Some x -> x + | None -> a let iter f = function | Some x -> f x | None -> () diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_lib_base.mli ocsigenserver-2.4.0/src/baselib/ocsigen_lib_base.mli --- ocsigenserver-2.2.0/src/baselib/ocsigen_lib_base.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_lib_base.mli 2014-04-16 16:01:15.000000000 +0000 @@ -54,6 +54,7 @@ type 'a t = 'a option val map : ('a -> 'b) -> 'a t -> 'b t val get : (unit -> 'a) -> 'a t -> 'a + val get' : 'a -> 'a t -> 'a val iter : ('a -> unit) -> 'a t -> unit val return : 'a -> 'a t val bind : 'a t -> ('a -> 'b t) -> 'b t @@ -69,13 +70,13 @@ val remove_first_if_any : 'a -> 'a list -> 'a list val remove_first_if_any_q : 'a -> 'a list -> 'a list - (* val remove_first : 'a -> 'a list -> 'a list *) - (* val remove_first_q : 'a -> 'a list -> 'a list *) - (* val remove_all : 'a -> 'a list -> 'a list *) - (* val remove_all_q : 'a -> 'a list -> 'a list *) + val remove_first : 'a -> 'a list -> 'a list + val remove_first_q : 'a -> 'a list -> 'a list + val remove_all : 'a -> 'a list -> 'a list + val remove_all_q : 'a -> 'a list -> 'a list val remove_all_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list - (* val remove_all_assoc_q : 'a -> ('a * 'b) list -> ('a * 'b) list *) - (* val is_prefix : 'a list -> 'a list -> bool *) + val remove_all_assoc_q : 'a -> ('a * 'b) list -> ('a * 'b) list + val is_prefix : 'a list -> 'a list -> bool val chop : int -> 'a list -> 'a list @@ -159,7 +160,6 @@ (* val recursively_remove_slash_at_beginning : path -> path *) val is_prefix_skip_end_slash : string list -> string list -> bool - val split_fragment : string -> string * string option end diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_lib.ml ocsigenserver-2.4.0/src/baselib/ocsigen_lib.ml --- ocsigenserver-2.2.0/src/baselib/ocsigen_lib.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_lib.ml 2014-04-16 16:01:15.000000000 +0000 @@ -23,184 +23,19 @@ (*****************************************************************************) module Ip_address = struct - - type t = - | IPv4 of int32 - | IPv6 of int64 * int64 - - exception Invalid_ipaddress of string - - let parse s = - let s = String.lowercase s in - let n = String.length s in - let is6 = String.contains s ':' in - let failwith fmt = Printf.ksprintf (fun s -> raise (Invalid_ipaddress s)) fmt in - - let rec parse_hex i accu = - match (if i < n then s.[i] else ':') with - | '0'..'9' as c -> parse_hex (i+1) (16*accu+(int_of_char c)-48) - | 'a'..'f' as c -> parse_hex (i+1) (16*accu+(int_of_char c)-87) - | _ -> (i, accu) - in - let rec parse_dec i accu = - match (if i < n then s.[i] else '.') with - | '0'..'9' as c -> parse_dec (i+1) (10*accu+(int_of_char c)-48) - | _ -> (i, accu) - in - let rec next_is_dec i = - if i < n then - match s.[i] with - | ':' -> false - | '.' -> true - | _ -> next_is_dec (i+1) - else false - in - let rec parse_component i accu nb = - if i < n then - if next_is_dec i then - let (i1, a) = parse_dec i 0 in - if i1 = i || (i1 < n && s.[i1] <> '.') then failwith "invalid dot notation in %s (1)" s; - let (i2, b) = parse_dec (i1+1) 0 in - if i2 = i1 then failwith "invalid dot notation in %s (2)" s; - let component = - if a < 0 || a > 255 || b < 0 || b > 255 then - failwith "invalid dot notation in %s (3)" s - else (a lsl 8) lor b - in - if i2 < n-1 && (s.[i2] = ':' || s.[i2] = '.') then - parse_component (i2+1) (component::accu) (nb+1) - else - (i2, component::accu, nb+1) - else if s.[i] = ':' then - parse_component (i+1) ((-1)::accu) nb - else - let (i1, a) = parse_hex i 0 in - if a < 0 || a > 0xffff then failwith "invalid colon notation in %s" s; - if i1 = i then - (i, accu, nb) - else if i1 < n-1 && s.[i1] = ':' then - parse_component (i1+1) (a::accu) (nb+1) - else - (i1, a::accu, nb+1) - else - (i, accu, nb) - in - - let (i, addr_list, size_list) = - if 1 < n && s.[0] = ':' && s.[1] = ':' then - parse_component 2 [-1] 0 - else - parse_component 0 [] 0 - in - - if size_list > 8 then failwith "too many components in %s" s; - - let maybe_mask = - if i < n && s.[i] = '/' then - let (i1, m) = parse_dec (i+1) 0 in - if i1 = i+1 || i1 < n || m < 0 || m > (if is6 then 128 else 32) then - failwith "invalid /n suffix in %s" s - else - Some m - else if i < n then - failwith "invalid suffix in %s (from index %i)" s i - else - None - in - - if is6 then - let (++) a b = Int64.logor (Int64.shift_left a 16) (Int64.of_int b) in - let normalized = - let rec aux_add n accu = - if n = 0 then accu else aux_add (n-1) (0::accu) - in - let rec aux_rev accu = function - | [] -> accu - | (-1)::q -> aux_rev (aux_add (8-size_list) accu) q - | a::q -> aux_rev (a::accu) q - in - aux_rev [] addr_list - in - let maybe_mask = match maybe_mask with - | Some n when n > 64 -> - Some (IPv6 (Int64.minus_one, Int64.shift_left Int64.minus_one (128-n))) - | Some n -> - Some (IPv6 (Int64.shift_left Int64.minus_one (64-n), Int64.zero)) - | None -> None - in - match normalized with - | [a; b; c; d; e; f; g; h] -> - IPv6 (Int64.zero ++ a ++ b ++ c ++ d, - Int64.zero ++ e ++ f ++ g ++ h), maybe_mask - | _ -> failwith "invalid IPv6 address: %s (%d components)" s (List.length normalized) - else - let (++) a b = Int32.logor (Int32.shift_left a 16) (Int32.of_int b) in - let maybe_mask = match maybe_mask with - | Some n -> - Some (IPv4 (Int32.shift_left Int32.minus_one (32-n))) - | None -> None - in - match addr_list with - | [b; a] -> - IPv4 (Int32.zero ++ a ++ b), maybe_mask - | _ -> failwith "invalid IPv4 address: %s" s - - - let match_ip (base, mask) ip = - match ip, base, mask with - | IPv4 a, IPv4 b, Some (IPv4 m) -> Int32.logand a m = Int32.logand b m - | IPv4 a, IPv4 b, None -> a = b - | IPv6 (a1,a2), IPv6 (b1,b2), Some (IPv6 (m1,m2)) -> - Int64.logand a1 m1 = Int64.logand b1 m1 && - Int64.logand a2 m2 = Int64.logand b2 m2 - | IPv6 (a1,a2), IPv6 (b1,b2), None -> a1 = b1 && a2 = b2 - | IPv6 (a1,a2), IPv4 b, c - when a1 = 0L && Int64.logand a2 0xffffffff00000000L = 0xffff00000000L -> - (* might be insecure, cf - http://tools.ietf.org/internet-drafts/draft-itojun-v6ops-v4mapped-harmful-02.txt *) - let a = Int64.to_int32 a2 in - begin match c with - | Some (IPv4 m) -> Int32.logand a m = Int32.logand b m - | Some (IPv6 _) -> invalid_arg "match_ip" - | None -> a = b - end - | _ -> false - - let network_of_ip ip mask4 (mask61, mask62) = match ip with - | IPv4 a -> IPv4 (Int32.logand a mask4) - | IPv6 (a, b) -> IPv6 (Int64.logand a mask61, Int64.logand b mask62) - exception No_such_host - let inet6_addr_loopback = - fst (parse (Unix.string_of_inet_addr Unix.inet6_addr_loopback)) - - let get_inet_addr host = + let get_inet_addr ?(v6=false) host = let rec aux = function | [] -> Lwt.fail No_such_host | {Unix.ai_addr=Unix.ADDR_INET (inet_addr, _)}::_ -> Lwt.return inet_addr | _::l -> aux l in + let options = [if v6 then Lwt_unix.AI_FAMILY Lwt_unix.PF_INET6 else Lwt_unix.AI_FAMILY Lwt_unix.PF_INET] in Lwt.bind - (Lwt_unix.getaddrinfo host "" []) + (Lwt_unix.getaddrinfo host "" options) aux -(* - let getnameinfo ia p = - try - Lwt_unix.getnameinfo (Unix.ADDR_INET (ia, p)) [Unix.NI_NAMEREQD] >>= fun r -> - Lwt.return r.Unix.ni_hostname - with - | Not_found -> - let hs = Unix.string_of_inet_addr ia in - Lwt.return - (if String.length hs > 7 && String.sub hs 0 7 = "::ffff:" - then String.sub hs 7 (String.length hs - 7) - else if String.contains hs ':' - then "["^hs^"]" - else hs) - - *) end (*****************************************************************************) diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_lib.mli ocsigenserver-2.4.0/src/baselib/ocsigen_lib.mli --- ocsigenserver-2.2.0/src/baselib/ocsigen_lib.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_lib.mli 2014-04-16 16:01:15.000000000 +0000 @@ -36,25 +36,8 @@ module String : module type of String_base module Ip_address : sig - - type t = - | IPv4 of int32 - | IPv6 of int64 * int64 - - (* exception Invalid_ipaddress of string *) - - val parse : string -> t * (t option) - val match_ip : t * (t option) -> t -> bool - val network_of_ip : t -> int32 -> int64 * int64 -> t - exception No_such_host - - val inet6_addr_loopback : t - - val get_inet_addr : string -> Unix.inet_addr Lwt.t - - (* val getnameinfo : Unix.inet_addr -> int -> string Lwt.t *) - + val get_inet_addr : ?v6:bool -> string -> Unix.inet_addr Lwt.t end module Filename : sig diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_messages.ml ocsigenserver-2.4.0/src/baselib/ocsigen_messages.ml --- ocsigenserver-2.2.0/src/baselib/ocsigen_messages.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_messages.ml 2014-04-16 16:01:15.000000000 +0000 @@ -24,6 +24,9 @@ let warning_file = "warnings.log" let error_file = "errors.log" + +let access_sect = Lwt_log.Section.make "access" + let full_path f = Filename.concat (Ocsigen_config.get_logdir ()) f let error_log_path () = full_path error_file @@ -37,6 +40,17 @@ (* CHECK: we are closing asynchronously! That should be ok, though. *) List.iter (fun l -> ignore (Lwt_log.close l : unit Lwt.t)) !loggers; + match Ocsigen_config.get_syslog_facility () with + | Some facility -> + (* log to syslog *) + let syslog = Lwt_log.syslog ~facility () in + loggers := [syslog]; + Lwt_log.default := Lwt_log.broadcast [syslog; stderr]; + Lwt.return () + + | None -> + (* log to files *) + let open_log path = let path = full_path path in try_lwt @@ -57,15 +71,15 @@ Lwt_log.broadcast [Lwt_log.dispatch (fun sect lev -> - if Lwt_log.Section.name sect = "access" then acc else + if sect = access_sect then acc else match lev with - Lwt_log.Error | Lwt_log.Fatal -> err + | Lwt_log.Error | Lwt_log.Fatal -> err | _ -> war); Lwt_log.dispatch (fun sect lev -> let show = match lev with - Lwt_log.Error | Lwt_log.Fatal -> + | Lwt_log.Error | Lwt_log.Fatal -> not (Ocsigen_config.get_silent ()) | _ -> Ocsigen_config.get_verbose () @@ -93,14 +107,12 @@ (****) -let access_sect = Lwt_log.Section.make "access" - let accesslog s = ignore (Lwt_log.notice ~section:access_sect s : unit Lwt.t) -let errlog s = ignore (Lwt_log.error s : unit Lwt.t) +let errlog ?section s = ignore (Lwt_log.error ?section s : unit Lwt.t) -let warning s = ignore (Lwt_log.warning s : unit Lwt.t) +let warning ?section s = ignore (Lwt_log.warning ?section s : unit Lwt.t) let unexpected_exception e s = warning ("Unexpected exception in "^s^": "^Printexc.to_string e) @@ -149,6 +161,43 @@ else (fun s -> ()) + +(*Dynamic log level changing*) + +module SectMap = Map.Make (String) +let sectmap = ref SectMap.empty + +let register_section s = sectmap := SectMap.add (Lwt_log.Section.name s) s !sectmap + +let find_section s = SectMap.find s !sectmap + +let level_of_string = function + | "Debug" | "debug" -> Some Lwt_log.Debug + | "Info" | "info" -> Some Lwt_log.Info + | "Notice" | "notice" -> Some Lwt_log.Notice + | "Warning" | "warning"-> Some Lwt_log.Warning + | "Error" | "error" -> Some Lwt_log.Error + | "Fatal" | "fatal" -> Some Lwt_log.Fatal + | _ -> None + +let command_f exc _ = function + | [sect_name] -> begin + try + Lwt_log.Section.reset_level (find_section sect_name); + with Not_found -> () + end; + Lwt.return () + | [sect_name; level_name] -> begin + try + match level_of_string level_name with + | None -> Lwt_log.Section.reset_level (find_section sect_name) + | Some l -> Lwt_log.Section.set_level (find_section sect_name) l + with Not_found -> () + end; + Lwt.return () + | _ -> Lwt.fail exc + + (* Re: [Caml-list] log function without evaluate arguments @@ -334,4 +383,3 @@ Caml-list mailing list. *) - diff -Nru ocsigenserver-2.2.0/src/baselib/ocsigen_messages.mli ocsigenserver-2.4.0/src/baselib/ocsigen_messages.mli --- ocsigenserver-2.2.0/src/baselib/ocsigen_messages.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/baselib/ocsigen_messages.mli 2014-04-16 16:01:15.000000000 +0000 @@ -23,10 +23,10 @@ val accesslog : string -> unit (** Write a message in errors.log *) -val errlog : string -> unit +val errlog : ?section:Lwt_log.section -> string -> unit (** Write a message in warnings.log *) -val warning : string -> unit +val warning : ?section:Lwt_log.section -> string -> unit (** Write a message only in debugging mode (-V option) - Non cooperative *) val debug : (unit -> string) -> unit @@ -57,7 +57,18 @@ (** Path to the error log file *) val error_log_path : unit -> string + +(** Register sections (so as to be able to dynamically change their level) + Level change is obtain by piping `logs: ` to the + Ocsigen command-pipe. Parameter must be the name of a + registered section (or else nothing happens), and must be one + of `Debug`, `Info`, `Notice`, `Warning`, `Error`, `Fatal` (or else the + default level is restored) + *) +val register_section: Lwt_log.section -> unit + (**/**) val open_files : ?user:string option -> ?group:string option -> unit -> unit Lwt.t val bip : int -> unit +val command_f : exn -> string -> string list -> unit Lwt.t diff -Nru ocsigenserver-2.2.0/src/extensions/accesscontrol.ml ocsigenserver-2.4.0/src/extensions/accesscontrol.ml --- ocsigenserver-2.2.0/src/extensions/accesscontrol.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/accesscontrol.ml 2014-04-16 16:01:15.000000000 +0000 @@ -43,16 +43,18 @@ let rec parse_condition = function | Element ("ip", ["value", s], []) -> - let ip_with_mask = + let prefix = try - Ip_address.parse s - with Failure _ -> - badconfig "Bad ip/netmask [%s] in condition" s + Ipaddr.Prefix.of_string_exn s + with Ipaddr.Parse_error _ -> + try + let ip = Ipaddr.of_string_exn s in + Ipaddr.Prefix.of_addr ip + with _ -> + badconfig "Bad ip/netmask [%s] in condition" s in (fun ri -> - let r = - Ip_address.match_ip ip_with_mask - (Lazy.force ri.ri_remote_ip_parsed) + let r = Ipaddr.Prefix.mem (Lazy.force ri.ri_remote_ip_parsed) prefix in if r then Ocsigen_messages.debug2 (sprintf "--Access control (ip): %s matches %s" ri.ri_remote_ip s) @@ -230,10 +232,10 @@ | Element ("nextsite", [], []) -> (function | Ocsigen_extensions.Req_found (_, r) -> - Lwt.return (Ocsigen_extensions.Ext_found_stop + Lwt.return (Ocsigen_extensions.Ext_found_stop (fun () -> Lwt.return r)) | Ocsigen_extensions.Req_not_found (err, ri) -> - Lwt.return (Ocsigen_extensions.Ext_stop_site + Lwt.return (Ocsigen_extensions.Ext_stop_site (Ocsigen_cookies.Cookies.empty, 404))) | Element ("nexthost", [], []) -> @@ -310,7 +312,7 @@ request | original_ip::proxies -> let last_proxy = List.last proxies in - let proxy_ip = fst (Ip_address.parse last_proxy) in + let proxy_ip = Ipaddr.of_string_exn last_proxy in let equal_ip = proxy_ip = Lazy.force request.request_info.ri_remote_ip_parsed in let need_equal_ip = match param with @@ -326,7 +328,7 @@ { request with request_info = { request.request_info with ri_remote_ip = original_ip; - ri_remote_ip_parsed = lazy (fst (Ip_address.parse original_ip)); + ri_remote_ip_parsed = lazy (Ipaddr.of_string_exn original_ip); ri_forward_ip = proxies; } } else (* the announced ip of the proxy is not its real ip *) ( Ocsigen_messages.warning (Printf.sprintf "--Access control: X-Forwarded-For: host ip ( %s ) does not match the header ( %s )" request.request_info.ri_remote_ip header ); diff -Nru ocsigenserver-2.2.0/src/extensions/extensiontemplate.ml ocsigenserver-2.4.0/src/extensions/extensiontemplate.ml --- ocsigenserver-2.2.0/src/extensions/extensiontemplate.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/extensiontemplate.ml 2014-04-16 16:01:15.000000000 +0000 @@ -32,7 +32,7 @@ *) (* To compile it: -ocamlfind ocamlc -thread -package netstring,ocsigen -c extensiontemplate.ml +ocamlfind ocamlc -thread -package netstring-pcre,ocsigen -c extensiontemplate.ml Then load it dynamically from Ocsigen's config file: diff -Nru ocsigenserver-2.2.0/src/extensions/Makefile ocsigenserver-2.4.0/src/extensions/Makefile --- ocsigenserver-2.2.0/src/extensions/Makefile 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/Makefile 2014-04-16 16:01:15.000000000 +0000 @@ -1,9 +1,11 @@ include ../../Makefile.config PACKAGE := lwt.unix \ + ipaddr \ lwt.ssl \ lwt.react \ netstring \ + netstring-pcre \ tyxml.parser \ LIBS := -I ../baselib -I ../http -I ../server ${addprefix -package ,${PACKAGE}} diff -Nru ocsigenserver-2.2.0/src/extensions/ocsigen_comet.ml ocsigenserver-2.4.0/src/extensions/ocsigen_comet.ml --- ocsigenserver-2.2.0/src/extensions/ocsigen_comet.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/ocsigen_comet.ml 2014-04-16 16:01:15.000000000 +0000 @@ -53,6 +53,8 @@ in aux accu1 accu2 lst +let section = Lwt_log.Section.make "Comet" +let () = OMsg.register_section section (*** EXTENSION OPTIONS ***) @@ -176,10 +178,13 @@ (* creation : newly created channel is stored in the map as a side effect *) let do_create name = if maxed_out_virtual_channels () - then (OMsg.warning "Too many virtual channels, associated exception raised"; - raise Too_many_virtual_channels) - else - let (read , write ) = Lwt.task () in + then begin + OMsg.warning + ~section + "Too many virtual channels, associated exception raised"; + raise Too_many_virtual_channels + end else + let (read , write) = Lwt.task () in let ch = { ch_id = name ; @@ -359,15 +364,22 @@ let activated, activate, deactivate = let activated = ref true in ((fun () -> !activated), - (fun () -> if !activated - then () - else (OMsg.warning "Comet is being activated"; - activated := true)), - (fun () -> if !activated - then (OMsg.warning "Comet is being deactivated"; - activated := false; - kill_all_connections ()) - else ()) + (fun () -> + if !activated then + () + else begin + OMsg.warning ~section "Comet is being activated"; + activated := true + end + ), + (fun () -> + if !activated then begin + OMsg.warning ~section "Comet is being deactivated"; + activated := false; + kill_all_connections () + end else + () + ) ) let warn_kill = diff -Nru ocsigenserver-2.2.0/src/extensions/ocsipersist-dbm/ocsipersist.ml ocsigenserver-2.4.0/src/extensions/ocsipersist-dbm/ocsipersist.ml --- ocsigenserver-2.2.0/src/extensions/ocsipersist-dbm/ocsipersist.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/ocsipersist-dbm/ocsipersist.ml 2014-04-16 16:01:15.000000000 +0000 @@ -238,17 +238,21 @@ let open_store name : store = name -let make_persistent_lazy ~store ~name ~default = +let make_persistent_lazy_lwt ~store ~name ~default = let pvname = (store, name) in (catch (fun () -> db_get pvname >>= (fun _ -> return ())) (function | Not_found -> - let def = Marshal.to_string (default ()) [] - in db_replace pvname def + default () >>= fun def -> + db_replace pvname (Marshal.to_string def []) | e -> fail e)) >>= (fun () -> return pvname) +let make_persistent_lazy ~store ~name ~default = + let default () = Lwt.wrap default in + make_persistent_lazy_lwt ~store ~name ~default + let make_persistent ~store ~name ~default = make_persistent_lazy ~store ~name ~default:(fun () -> default) diff -Nru ocsigenserver-2.2.0/src/extensions/ocsipersist.mli ocsigenserver-2.4.0/src/extensions/ocsipersist.mli --- ocsigenserver-2.2.0/src/extensions/ocsipersist.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/ocsipersist.mli 2014-04-16 16:01:15.000000000 +0000 @@ -56,6 +56,11 @@ if needed *) +val make_persistent_lazy_lwt : + store:store -> name:string -> default:(unit -> 'a Lwt.t) -> 'a t Lwt.t +(** Lwt version of make_persistent_lazy. +*) + val get : 'a t -> 'a Lwt.t (** [get pv] gives the value of [pv] *) diff -Nru ocsigenserver-2.2.0/src/extensions/ocsipersist-sqlite/ocsipersist.ml ocsigenserver-2.4.0/src/extensions/ocsipersist-sqlite/ocsipersist.ml --- ocsigenserver-2.2.0/src/extensions/ocsipersist-sqlite/ocsipersist.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/ocsipersist-sqlite/ocsipersist.ml 2014-04-16 16:01:15.000000000 +0000 @@ -228,18 +228,22 @@ let s = "store___"^name in db_create s -let make_persistent_lazy ~store ~name ~default = +let make_persistent_lazy_lwt ~store ~name ~default = store >>= fun store -> let pvname = (store, name) in (catch (fun () -> db_get pvname >>= (fun _ -> return ())) (function | Not_found -> - let def = Marshal.to_string (default ()) [] - in db_replace pvname def + default () >>= fun def -> + db_replace pvname (Marshal.to_string def []) | e -> fail e)) >>= (fun () -> return pvname) +let make_persistent_lazy ~store ~name ~default = + let default () = Lwt.wrap default in + make_persistent_lazy_lwt ~store ~name ~default + let make_persistent ~store ~name ~default = make_persistent_lazy ~store ~name ~default:(fun () -> default) diff -Nru ocsigenserver-2.2.0/src/extensions/redirectmod.ml ocsigenserver-2.4.0/src/extensions/redirectmod.ml --- ocsigenserver-2.2.0/src/extensions/redirectmod.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/redirectmod.ml 2014-04-16 16:01:15.000000000 +0000 @@ -25,7 +25,7 @@ (*****************************************************************************) (* To compile it: -ocamlfind ocamlc -thread -package netstring,ocsigen -c extensiontemplate.ml +ocamlfind ocamlc -thread -package netstring-pcre,ocsigen -c extensiontemplate.ml Then load it dynamically from Ocsigen's config file: diff -Nru ocsigenserver-2.2.0/src/extensions/rewritemod.ml ocsigenserver-2.4.0/src/extensions/rewritemod.ml --- ocsigenserver-2.2.0/src/extensions/rewritemod.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/extensions/rewritemod.ml 2014-04-16 16:01:15.000000000 +0000 @@ -35,7 +35,7 @@ (* To compile it: -ocamlfind ocamlc -thread -package netstring,ocsigen -c extensiontemplate.ml +ocamlfind ocamlc -thread -package netstring-pcre,ocsigen -c extensiontemplate.ml Then load it dynamically from Ocsigen's config file: diff -Nru ocsigenserver-2.2.0/src/files/META.in ocsigenserver-2.4.0/src/files/META.in --- ocsigenserver-2.2.0/src/files/META.in 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/files/META.in 2014-04-16 16:01:15.000000000 +0000 @@ -32,7 +32,7 @@ version = "[distributed with Ocsigen server]" requires = "%%BASEDEPS%%" archive(byte) = "ocsigen_lib_base.cmo" - archive(native) = "ocsigen_lib_base.cmxo" + archive(native) = "ocsigen_lib_base.cmx" ) ) @@ -56,6 +56,7 @@ package "redirectmod" ( exists_if = "redirectmod.cmo,redirectmod.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "HTTP redirections" archive(byte) = "redirectmod.cmo" @@ -64,6 +65,7 @@ package "outputfilter" ( exists_if = "outputfilter.cmo,outputfilter.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "Changing HTTP answers before sending" archive(byte) = "outputfilter.cmo" @@ -72,6 +74,7 @@ package "userconf" ( exists_if = "userconf.cmo,userconf.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "Allowing users to have their own configuration files" archive(byte) = "userconf.cmo" @@ -80,6 +83,7 @@ package "staticmod" ( exists_if = "staticmod.cmo,staticmod.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "Serving static files" archive(byte) = "staticmod.cmo" @@ -96,6 +100,7 @@ package "accesscontrol" ( exists_if = "accesscontrol.cmo,accesscontrol.cmx" + requires = "ocsigenserver,ipaddr" version = "[distributed with Ocsigen server]" description = "Filtering HTTP requests" archive(byte) = "accesscontrol.cmo" @@ -104,6 +109,7 @@ package "cors" ( exists_if = "cors.cmo,cors.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "Handling cross-origin requests" archive(byte) = "cors.cmo" @@ -112,6 +118,7 @@ package "extendconfiguration" ( exists_if = "extendconfiguration.cmo,extendconfiguration.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "Updating server options" archive(byte) = "extendconfiguration.cmo" @@ -120,6 +127,7 @@ package "authbasic" ( exists_if = "authbasic.cmo,authbasic.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "Basic HTTP Authentication" archive(byte) = "authbasic.cmo" @@ -153,7 +161,7 @@ package "deflatemod" ( exists_if = "deflatemod.cmo,deflatemod.cmx" - requires = "%%CAMLZIPNAME%%" + requires = "ocsigenserver,%%CAMLZIPNAME%%" version = "[distributed with Ocsigen server]" description = "Compressing HTTP reply bodies" archive(byte) = "deflatemod.cmo" @@ -162,6 +170,7 @@ package "rewritemod" ( exists_if = "rewritemod.cmo,rewritemod.cmx" + requires = "ocsigenserver" version = "[distributed with Ocsigen server]" description = "Rewriting URLs" archive(byte) = "rewritemod.cmo" @@ -170,7 +179,7 @@ package "comet" ( exists_if = "ocsigen_comet.cmo,ocsigen_comet.cmx" - requires = "lwt.react" + requires = "ocsigenserver,lwt.react" version = "[distributed with Ocsigen server]" description = "Comet server-to-client communication" archive(byte) = "ocsigen_comet.cmo" diff -Nru ocsigenserver-2.2.0/src/files/mime.types ocsigenserver-2.4.0/src/files/mime.types --- ocsigenserver-2.2.0/src/files/mime.types 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/files/mime.types 2014-04-16 16:01:15.000000000 +0000 @@ -29,8 +29,6 @@ application/edi-x12 application/eshop application/font-tdpfr -application/font-woff woff -application/x-font-ttf ttf application/http application/hyperstudio application/iges @@ -251,6 +249,7 @@ application/vnd.ms-artgalry application/vnd.ms-asf application/vnd.ms-excel xls +application/vnd.ms-fontobject eot application/vnd.ms-lrm application/vnd.ms-powerpoint ppt application/vnd.ms-project @@ -353,6 +352,8 @@ application/x-csh csh application/x-director dcr dir dxr application/x-dvi dvi +application/x-font-ttf ttf +application/x-font-woff woff application/x-futuresplash spl application/x-gtar gtar application/x-gzip diff -Nru ocsigenserver-2.2.0/src/http/http_headers.ml ocsigenserver-2.4.0/src/http/http_headers.ml --- ocsigenserver-2.2.0/src/http/http_headers.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/http_headers.ml 2014-04-16 16:01:15.000000000 +0000 @@ -36,6 +36,7 @@ let cookie = name "Cookie" let date = name "Date" let etag = name "ETag" +let expect = name "Expect" let expires = name "Expires" let host = name "Host" let if_match = name "If-Match" diff -Nru ocsigenserver-2.2.0/src/http/http_headers.mli ocsigenserver-2.4.0/src/http/http_headers.mli --- ocsigenserver-2.2.0/src/http/http_headers.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/http_headers.mli 2014-04-16 16:01:15.000000000 +0000 @@ -43,6 +43,7 @@ val cookie : name val date : name val etag : name +val expect: name val expires : name val host : name val if_match : name diff -Nru ocsigenserver-2.2.0/src/http/Makefile ocsigenserver-2.4.0/src/http/Makefile --- ocsigenserver-2.2.0/src/http/Makefile 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/Makefile 2014-04-16 16:01:15.000000000 +0000 @@ -1,6 +1,6 @@ include ../../Makefile.config -LIBS := -package netstring,lwt.ssl,tyxml -I ../baselib +LIBS := -package netstring,netstring-pcre,lwt.ssl,tyxml -I ../baselib OCAMLC := $(OCAMLFIND) ocamlc${BYTEDBG} OCAMLOPT := $(OCAMLFIND) ocamlopt ${OPTDBG} OCAMLDOC := $(OCAMLFIND) ocamldoc diff -Nru ocsigenserver-2.2.0/src/http/ocsigen_charset_mime.ml ocsigenserver-2.4.0/src/http/ocsigen_charset_mime.ml --- ocsigenserver-2.2.0/src/http/ocsigen_charset_mime.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/ocsigen_charset_mime.ml 2014-04-16 16:01:15.000000000 +0000 @@ -152,7 +152,7 @@ close_in in_ch; map with Sys_error s -> - Ocsigen_messages.warning + Ocsigen_messages.errlog (Printf.sprintf "Ocsigen_charser_mime: unable to read the mime.types file (Error: %s)." s); MapString.empty )]; diff -Nru ocsigenserver-2.2.0/src/http/ocsigen_headers.ml ocsigenserver-2.4.0/src/http/ocsigen_headers.ml --- ocsigenserver-2.2.0/src/http/ocsigen_headers.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/ocsigen_headers.ml 2014-04-16 16:01:15.000000000 +0000 @@ -156,8 +156,8 @@ (* RFC 2616, sect. 14.23 *) (* XXX Not so simple: the host name may contain a colon! (RFC 3986) *) let get_host_from_host_header = - let host_re = - Netstring_pcre.regexp "^(\\[[0-9A-Fa-f:.]+\\]|[^:]+)(:([0-9]+))?$" + let host_re = + Netstring_pcre.regexp "^(\\[[0-9A-Fa-f:.]+\\]|[^:]+)(:([0-9]+))?$" in fun http_frame -> try @@ -166,9 +166,9 @@ http_frame.Ocsigen_http_frame.frame_header Http_headers.host in match Netstring_pcre.string_match host_re hostport 0 with - | Some m -> + | Some m -> (Some (Netstring_pcre.matched_group m 1 hostport), - try Some (int_of_string + try Some (int_of_string (Netstring_pcre.matched_group m 3 hostport)) with Not_found -> None | Failure _ -> raise Ocsigen_Bad_Request) | None -> raise Ocsigen_Bad_Request @@ -187,6 +187,16 @@ with Not_found -> None +let get_expect http_frame = + try + String.split ',' ( + Http_header.get_headers_value + http_frame.Ocsigen_http_frame.frame_header + Http_headers.expect + ) + with Not_found -> + [] + let get_if_modified_since http_frame = try Some (Netdate.parse_epoch @@ -237,18 +247,17 @@ match String.split ';' s with | [] -> None | a::l -> - try - let (typ, subtype) = String.sep '/' a in - let params = - try - List.map (String.sep '=') l - with Not_found -> [] - in + try + let typ, subtype = String.sep '/' a in + let params = + try + List.map (String.sep '=') l + with Not_found -> [] + in (*VVV If syntax error, we return no parameter at all *) - Some ((typ, subtype), params) - with Not_found -> None + Some ((typ, subtype), params) (*VVV If syntax error in type, we return None *) - + with Not_found -> None let get_content_length http_frame = try @@ -336,4 +345,3 @@ (Http_header.get_headers_values http_frame.Ocsigen_http_frame.frame_header Http_headers.accept_language) with _ -> [] - diff -Nru ocsigenserver-2.2.0/src/http/ocsigen_headers.mli ocsigenserver-2.4.0/src/http/ocsigen_headers.mli --- ocsigenserver-2.2.0/src/http/ocsigen_headers.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/ocsigen_headers.mli 2014-04-16 16:01:15.000000000 +0000 @@ -35,16 +35,18 @@ val get_keepalive : Ocsigen_http_frame.Http_header.http_header -> bool val parse_cookies : string -> string CookiesTable.t val parse_mime_type : string -> string option * string option -val get_host_from_host_header : Ocsigen_http_frame.t -> +val get_host_from_host_header : Ocsigen_http_frame.t -> string option * int option val get_user_agent : Ocsigen_http_frame.t -> string val get_cookie_string : Ocsigen_http_frame.t -> string option +val get_expect : Ocsigen_http_frame.t -> string list val get_if_modified_since : Ocsigen_http_frame.t -> float option val get_if_unmodified_since : Ocsigen_http_frame.t -> float option val get_if_none_match : Ocsigen_http_frame.t -> string list option val get_if_match : Ocsigen_http_frame.t -> string list option val get_content_type : Ocsigen_http_frame.t -> string option -val parse_content_type : string option -> ((string * string) * (string * string) list) option +val parse_content_type + : string option -> ((string * string) * (string * string) list) option val get_content_length : Ocsigen_http_frame.t -> int64 option val get_referer : Ocsigen_http_frame.t -> string option val get_referrer : Ocsigen_http_frame.t -> string option diff -Nru ocsigenserver-2.2.0/src/http/ocsigen_http_com.ml ocsigenserver-2.4.0/src/http/ocsigen_http_com.ml --- ocsigenserver-2.2.0/src/http/ocsigen_http_com.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/ocsigen_http_com.ml 2014-04-16 16:01:15.000000000 +0000 @@ -731,6 +731,18 @@ observer := (fun a b -> o a b >>= fun () -> f a b)), (fun a b -> !observer a b)) +let send_100_continue slot = + wait_previous_senders slot >>= fun () -> + let out_ch = slot.sl_chan in + Ocsigen_messages.debug2 "writing 100-continue"; + let hh = Framepp.string_of_header { + H.mode = H.Answer 100; + proto = H.HTTP11; + headers = Http_headers.empty + } in + Ocsigen_messages.debug2 hh; + Lwt_chan.output_string out_ch hh + (** Sends the HTTP frame. * The headers are merged with those of the sender, the priority * being given to the newly defined header in case of conflict. diff -Nru ocsigenserver-2.2.0/src/http/ocsigen_http_com.mli ocsigenserver-2.4.0/src/http/ocsigen_http_com.mli --- ocsigenserver-2.2.0/src/http/ocsigen_http_com.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/ocsigen_http_com.mli 2014-04-16 16:01:15.000000000 +0000 @@ -82,7 +82,8 @@ (** Sender with only the server name, and HTTP/1.1 *) val default_sender : sender_type - +(** send an HTTP/1.1 100 Continue message *) +val send_100_continue : slot -> unit Lwt.t (** send an HTTP message. [send] may also fail with [Interrupted_stream] exception if the input diff -Nru ocsigenserver-2.2.0/src/http/ocsigen_senders.ml ocsigenserver-2.4.0/src/http/ocsigen_senders.ml --- ocsigenserver-2.2.0/src/http/ocsigen_senders.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/http/ocsigen_senders.ml 2014-04-16 16:01:15.000000000 +0000 @@ -114,10 +114,10 @@ res_headers= Http_headers.dyn_headers; res_stream = (Ocsigen_stream.make - (fun () -> + (fun () -> Ocsigen_stream.cont c (fun () -> Ocsigen_stream.empty None)), None) - + } end @@ -195,7 +195,7 @@ {default_result with res_content_length = None; res_etag = get_etag c; - res_stream = + res_stream = (Ocsigen_stream.make ~finalize (fun _ -> next_stream c), None); res_headers= Http_headers.dyn_headers; res_content_type = Some ct} diff -Nru ocsigenserver-2.2.0/src/Makefile ocsigenserver-2.4.0/src/Makefile --- ocsigenserver-2.2.0/src/Makefile 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/Makefile 2014-04-16 16:01:15.000000000 +0000 @@ -64,6 +64,7 @@ > $@ ../local/etc/$(PROJECTNAME).conf: files/${PROJECTNAME}.conf.in ../Makefile.config Makefile + mkdir -p ../local/etc ../local/var/log ../local/var/run cat $< \ | sed s%80\%8080\%g \ | sed s%_LOGDIR_%$(SRC)/local/var/log%g \ diff -Nru ocsigenserver-2.2.0/src/server/ocsigen_extensions.ml ocsigenserver-2.4.0/src/server/ocsigen_extensions.ml --- ocsigenserver-2.2.0/src/server/ocsigen_extensions.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/server/ocsigen_extensions.ml 2014-04-16 16:01:15.000000000 +0000 @@ -151,6 +151,7 @@ default_hostname: string; default_httpport: int; default_httpsport: int; + default_protocol_is_https: bool; mime_assoc: Ocsigen_charset_mime.mime_assoc; @@ -192,7 +193,7 @@ filesize: int64; raw_original_filename: string; original_basename: string ; - file_content_type: (string * string option) option; + file_content_type: ((string * string) * (string * string) list) option; } type request_info = @@ -215,7 +216,7 @@ ri_files: (config_info -> (string * file_info) list Lwt.t) option; (** Files sent in the request (multipart data). None if other content type or no content. *) ri_remote_inet_addr: Unix.inet_addr; (** IP of the client *) ri_remote_ip: string; (** IP of the client *) - ri_remote_ip_parsed: Ip_address.t Lazy.t; (** IP of the client, parsed *) + ri_remote_ip_parsed: Ipaddr.t Lazy.t; (** IP of the client, parsed *) ri_remote_port: int; (** Port used by the client *) ri_forward_ip: string list; (** IPs of gateways the request went throught *) ri_server_port: int; (** Port of the request (server) *) @@ -255,12 +256,12 @@ extensions *) ri_client: client; (** The request connection *) - ri_range: ((int64 * int64) list * int64 option * ifrange) option Lazy.t; - (** Range HTTP header. [None] means all the document. + ri_range: ((int64 * int64) list * int64 option * ifrange) option Lazy.t; + (** Range HTTP header. [None] means all the document. List of intervals + possibly from an index to the end of the document. *) ri_timeofday: float; (** An Unix timestamp computed at the beginning of the request *) - mutable ri_nb_tries: int; (** For internal use: + mutable ri_nb_tries: int; (** For internal use: used to prevent loops of requests *) ri_connection_closed: unit Lwt.t; (** a thread waking up when the connection is closed *) @@ -341,7 +342,7 @@ the parsing function (of type [parse_fun]), that will return something of type [extension2]. *) - | Ext_found_continue_with of + | Ext_found_continue_with of (unit -> (Ocsigen_http_frame.result * request) Lwt.t) (** Same as [Ext_found] but may modify the request. *) | Ext_found_continue_with' of (Ocsigen_http_frame.result * request) @@ -567,8 +568,8 @@ Lwt.return (Ext_found_continue_with' (r, oldri), cookies_to_set) | (Ext_do_nothing, cookies_to_set) -> - Lwt.return - (Ext_continue_with (oldri, + Lwt.return + (Ext_continue_with (oldri, Ocsigen_cookies.Cookies.empty, e), cookies_to_set) | r -> Lwt.return r @@ -689,7 +690,7 @@ try oldf parse_config config_tag with - | Bad_config_tag_for_extension c -> + | Bad_config_tag_for_extension c -> newf parse_config config_tag )); @@ -708,7 +709,7 @@ try oldf parse_config config_tag with - | Bad_config_tag_for_extension c -> + | Bad_config_tag_for_extension c -> newf parse_config config_tag )); @@ -744,7 +745,7 @@ | _ -> raise (Error_in_config_file (Printf.sprintf "Unexpected content found in configuration of extension %s: %s does not accept options" ext_name ext_name)) -let register_extension +let register_extension ~name ?fun_site ?user_fun_site @@ -1079,7 +1080,7 @@ let mvar = Lwt_mvar.create_empty () in ((fun () -> !connected), (fun n -> connected := !connected + n), - (fun () -> + (fun () -> let c = !connected in connected := c - 1; if !connected <= 0 && !sockets = [] && !sslsockets = [] @@ -1092,7 +1093,7 @@ end else Lwt.return () ), - (fun max -> + (fun max -> maxr := max; Lwt_mvar.take mvar) ) @@ -1107,7 +1108,7 @@ (*****************************************************************************) -(* Default hostname is either the Host header or the hostname set in +(* Default hostname is either the Host header or the hostname set in the configuration file. *) let get_hostname req = if Ocsigen_config.get_usedefaulthostname () @@ -1177,7 +1178,7 @@ exception Not_concerned let find_redirection regexp full_url dest - https host port + https host port get_params_string sub_path_string full_path_string @@ -1218,16 +1219,22 @@ let register_command_function, get_command_function = let command_function = ref (fun ?prefix _ _ -> Lwt.fail Unknown_command) in - ((fun ?prefix f -> + ((fun ?prefix f -> let prefix' = prefix in let old_command_function = !command_function in - command_function := - (fun ?prefix s c -> + command_function := + (fun ?prefix s c -> Lwt.catch (fun () -> old_command_function ?prefix s c) (function - | Unknown_command -> + | Unknown_command -> if prefix = prefix' then f s c else Lwt.fail Unknown_command | e -> Lwt.fail e))), (fun () -> !command_function)) + + +let () = + register_command_function + ~prefix:"logs" + (Ocsigen_messages.command_f Unknown_command) diff -Nru ocsigenserver-2.2.0/src/server/ocsigen_extensions.mli ocsigenserver-2.4.0/src/server/ocsigen_extensions.mli --- ocsigenserver-2.2.0/src/server/ocsigen_extensions.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/server/ocsigen_extensions.mli 2014-04-16 16:01:15.000000000 +0000 @@ -88,6 +88,7 @@ default_hostname: string; default_httpport: int; default_httpsport: int; + default_protocol_is_https: bool; mime_assoc: Ocsigen_charset_mime.mime_assoc; @@ -139,7 +140,7 @@ filesize: int64; raw_original_filename: string; original_basename: string ; - file_content_type: (string * string option) option; + file_content_type: ((string * string) * (string * string) list) option; } (** The request *) @@ -163,7 +164,7 @@ ri_files: (config_info -> (string * file_info) list Lwt.t) option; (** Files sent in the request (multipart data). None if other content type or no content. *) ri_remote_inet_addr: Unix.inet_addr; (** IP of the client *) ri_remote_ip: string; (** IP of the client *) - ri_remote_ip_parsed: Ip_address.t Lazy.t; (** IP of the client, parsed *) + ri_remote_ip_parsed: Ipaddr.t Lazy.t; (** IP of the client, parsed *) ri_remote_port: int; (** Port used by the client *) ri_forward_ip: string list; (** IPs of gateways the request went throught *) ri_server_port: int; (** Port of the request (server) *) @@ -203,12 +204,12 @@ extensions *) ri_client: client; (** The request connection *) - ri_range: ((int64 * int64) list * int64 option * ifrange) option Lazy.t; - (** Range HTTP header. [None] means all the document. + ri_range: ((int64 * int64) list * int64 option * ifrange) option Lazy.t; + (** Range HTTP header. [None] means all the document. List of intervals + possibly from an index to the end of the document. *) ri_timeofday: float; (** An Unix timestamp computed at the beginning of the request *) - mutable ri_nb_tries: int; (** For internal use: + mutable ri_nb_tries: int; (** For internal use: used to prevent loops of requests *) ri_connection_closed: unit Lwt.t; (** a thread waking up when the connection is closed *) @@ -294,7 +295,7 @@ the parsing function (of type [parse_fun]), that will return something of type [extension2]. *) - | Ext_found_continue_with of + | Ext_found_continue_with of (unit -> (Ocsigen_http_frame.result * request) Lwt.t) (** Same as [Ext_found] but may modify the request. *) | Ext_found_continue_with' of (Ocsigen_http_frame.result * request) @@ -500,7 +501,7 @@ end (** Returns the hostname to be used for absolute links or redirections. - It is either the Host header or the hostname set in + It is either the Host header or the hostname set in the configuration file. *) val get_hostname : request -> string @@ -547,7 +548,7 @@ exception Unknown_command (** Use a prefix for all your commands when you want to create - extension-specific commands. + extension-specific commands. For example if the prefix is "myextension" and the commande "blah", the actual command to be written by the user is "myextension:blah". Give as parameter the function that will parse the command and do an action. @@ -608,4 +609,3 @@ val sockets : Lwt_unix.file_descr list ref val sslsockets : Lwt_unix.file_descr list ref - diff -Nru ocsigenserver-2.2.0/src/server/ocsigen_http_client.ml ocsigenserver-2.4.0/src/server/ocsigen_http_client.ml --- ocsigenserver-2.2.0/src/server/ocsigen_http_client.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/server/ocsigen_http_client.ml 2014-04-16 16:01:15.000000000 +0000 @@ -82,7 +82,7 @@ let (>>=) = Lwt.(>>=) -(* let _ = Ssl_threads.init () (* Does not work for now (deadlock) -- +(* let _ = Ssl_threads.init () (* Does not work for now (deadlock) -- bug in ocamlssl *) *) let _ = Ssl.init () let sslcontext = ref (Ssl.create_context Ssl.SSLv23 Ssl.Both_context) @@ -106,13 +106,13 @@ The connection table associates to each incoming connection (called "client") the thread and information about the output requests, in order to try to pipeline them on the same output connection. - + If the client parameter is not present, we do the requests independantly. We try to find a free connection to the right server or we create one if there is none. In that case, the distant server may have the request in wrong order. - + If there is a body in the request we want to do, we do not try to pipeline, even if it comes from the same client. We use a free (or new) connection. @@ -367,18 +367,18 @@ let new_conn () = let sockaddr = Unix.ADDR_INET (inet_addr, port) in - let fd = - Lwt_unix.socket (Unix.domain_of_sockaddr sockaddr) Unix.SOCK_STREAM 0 + let fd = + Lwt_unix.socket (Unix.domain_of_sockaddr sockaddr) Unix.SOCK_STREAM 0 in Lwt_unix.set_close_on_exec fd; let thr_conn = + let timeout = + Lwt_timeout.create (Ocsigen_config.get_server_timeout ()) + (fun () -> try Lwt_unix.shutdown fd Unix.SHUTDOWN_RECEIVE with _ -> ()); + in Lwt.catch (fun () -> - let timeout = - Lwt_timeout.create (Ocsigen_config.get_server_timeout ()) - (fun () -> Lwt_unix.shutdown fd Unix.SHUTDOWN_RECEIVE); - in Lwt_timeout.start timeout; Lwt_unix.connect fd sockaddr >>= fun () -> @@ -392,7 +392,8 @@ Lwt.return (Ocsigen_http_com.create_receiver (Ocsigen_config.get_server_timeout ()) Ocsigen_http_com.Answer socket)) - (handle_connection_error fd) + (Lwt_timeout.stop timeout; + handle_connection_error fd) in let gf = thr_conn >>= fun conn -> @@ -524,12 +525,12 @@ Ocsigen_http_frame.res_content_length= content_length; Ocsigen_http_frame.res_headers= headers; }) >>= fun () -> - + Ocsigen_messages.debug2 "--Ocsigen_http_client: request sent"; Lwt.wakeup request_sent_awakener (); Lwt.return ()) (fun e -> Lwt.wakeup_exn request_sent_awakener e; Lwt.fail e) - + in @@ -704,8 +705,8 @@ (*****************************************************************************) -let get ?https ?port ?headers ~host ~uri () = - Ip_address.get_inet_addr host >>= fun inet_addr -> +let get ?v6 ?https ?port ?headers ~host ~uri () = + Ip_address.get_inet_addr ?v6 host >>= fun inet_addr -> raw_request ?https ?port @@ -718,16 +719,16 @@ () () -let get_url ?headers url = +let get_url ?v6 ?headers url = let (https, host, port, uri, _, _, _) = Url.parse url in let host = match host with None -> "localhost" | Some h -> h in let uri = "/"^uri in - get ?https ?port ?headers ~host ~uri () + get ?v6 ?https ?port ?headers ~host ~uri () (*****************************************************************************) -let post_string ?https ?port ?(headers = Http_headers.empty) +let post_string ?v6 ?https ?port ?(headers = Http_headers.empty) ~host ~uri ~content ~content_type () = - Ip_address.get_inet_addr host >>= fun inet_addr -> + Ip_address.get_inet_addr ?v6 host >>= fun inet_addr -> let content_type = String.concat "/" [fst content_type; snd content_type] in raw_request ?https @@ -742,26 +743,26 @@ () () -let post_string_url ?headers ~content ~content_type url = +let post_string_url ?v6 ?headers ~content ~content_type url = let (https, host, port, uri, _, _, _) = Url.parse url in let host = match host with None -> "localhost" | Some h -> h in let uri = "/"^uri in - post_string ?https ?port ?headers ~host ~uri ~content ~content_type () + post_string ?v6 ?https ?port ?headers ~host ~uri ~content ~content_type () (*****************************************************************************) -let post_urlencoded ?https ?port ?headers ~host ~uri ~content () = - post_string ?https ?port ?headers +let post_urlencoded ?v6 ?https ?port ?headers ~host ~uri ~content () = + post_string ?v6 ?https ?port ?headers ~host ~uri - ~content:(Netencoding.Url.mk_url_encoded_parameters content) + ~content:(Netencoding.Url.mk_url_encoded_parameters content) ~content_type:("application","x-www-form-urlencoded") () -let post_urlencoded_url ?headers ~content url = +let post_urlencoded_url ?v6 ?headers ~content url = let (https, host, port, uri, _, _, _) = Url.parse url in let host = match host with None -> "localhost" | Some h -> h in let uri = "/"^uri in - post_urlencoded ?https ?port ?headers ~host ~uri ~content () + post_urlencoded ?v6 ?https ?port ?headers ~host ~uri ~content () (*****************************************************************************) let basic_raw_request @@ -773,8 +774,8 @@ | Some p -> p in let sockaddr = Unix.ADDR_INET (inet_addr, port) in - let fd = - Lwt_unix.socket (Unix.domain_of_sockaddr sockaddr) Unix.SOCK_STREAM 0 + let fd = + Lwt_unix.socket (Unix.domain_of_sockaddr sockaddr) Unix.SOCK_STREAM 0 in Lwt_unix.set_close_on_exec fd; diff -Nru ocsigenserver-2.2.0/src/server/ocsigen_http_client.mli ocsigenserver-2.4.0/src/server/ocsigen_http_client.mli --- ocsigenserver-2.2.0/src/server/ocsigen_http_client.mli 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/server/ocsigen_http_client.mli 2014-04-16 16:01:15.000000000 +0000 @@ -20,6 +20,7 @@ (** Using Ocsigen as a HTTP client *) val get : + ?v6:bool -> ?https: bool -> ?port:int -> ?headers: Http_headers.t -> @@ -35,14 +36,15 @@ {!Ocsigen_stream.finalize}, otherwise you will have fd leaks. *) -val get_url : ?headers: Http_headers.t -> string -> Ocsigen_http_frame.t Lwt.t -(** Do a GET HTTP request. The string must be a full URL. +val get_url : ?v6:bool -> ?headers: Http_headers.t -> string -> Ocsigen_http_frame.t Lwt.t +(** Do a GET HTTP request. The string must be a full URL. Warning: the stream must be finalized manually after reading, using {!Ocsigen_stream.finalize}, otherwise you will have fd leaks. *) val post_string : + ?v6:bool -> ?https: bool -> ?port:int -> ?headers: Http_headers.t -> @@ -61,18 +63,20 @@ *) val post_string_url : + ?v6:bool -> ?headers: Http_headers.t -> content:string -> content_type:(string * string) -> string -> Ocsigen_http_frame.t Lwt.t -(** Do a GET HTTP request. The string must be a full URL. +(** Do a GET HTTP request. The string must be a full URL. Warning: the stream must be finalized manually after reading, using {!Ocsigen_stream.finalize}, otherwise you will have fd leaks. *) val post_urlencoded : + ?v6:bool -> ?https: bool -> ?port:int -> ?headers: Http_headers.t -> @@ -90,12 +94,13 @@ *) val post_urlencoded_url : + ?v6:bool -> ?headers: Http_headers.t -> content:(string * string) list -> string -> Ocsigen_http_frame.t Lwt.t (** Do a GET HTTP request with URL encoded parameters as content. - The string must be a full URL. + The string must be a full URL. Warning: the stream must be finalized manually after reading, using {!Ocsigen_stream.finalize}, otherwise you will have fd leaks. @@ -171,7 +176,7 @@ uri:string -> unit -> Ocsigen_http_frame.t Lwt.t -(** Same as {!Ocsigen_http_client.raw_request}, +(** Same as {!Ocsigen_http_client.raw_request}, but does not try to reuse connections. Opens a new connections for each request. Far less efficient. *) diff -Nru ocsigenserver-2.2.0/src/server/ocsigen_parseconfig.ml ocsigenserver-2.4.0/src/server/ocsigen_parseconfig.ml --- ocsigenserver-2.2.0/src/server/ocsigen_parseconfig.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/server/ocsigen_parseconfig.ml 2014-04-16 16:01:15.000000000 +0000 @@ -42,8 +42,8 @@ try (*VVV Is it ok? Is it reliable? *) (List.hd - (Unix.getaddrinfo hostname "www" - [Unix.AI_CANONNAME; + (Unix.getaddrinfo hostname "www" + [Unix.AI_CANONNAME; Unix.AI_SOCKTYPE Unix.SOCK_STREAM])).Unix.ai_canonname with Failure _ -> let warning = @@ -101,7 +101,7 @@ else if (c1 = "k") then Int64.mul kibi (v l1) - else + else let l2 = l-2 in if l2>0 then @@ -117,7 +117,7 @@ else if (c2 = "ko") || (c2 = "kB") then Int64.mul kilo (v l2) - else + else let l3 = l-3 in if l3>0 then @@ -139,12 +139,12 @@ else o l) -let parse_size_tag tag s = +let parse_size_tag tag s = try - parse_size s - with Failure _ -> + parse_size s + with Failure _ -> raise - (Ocsigen_config.Config_file_error + (Ocsigen_config.Config_file_error ("While parsing <"^tag^"> - "^s^" is not a valid size.")) @@ -163,12 +163,12 @@ | (PCData s)::l -> s^(parse_string l) | _ -> failwith "ocsigen_parseconfig.parse_string" -let parse_string_tag tag s = +let parse_string_tag tag s = try - parse_string s - with Failure _ -> + parse_string s + with Failure _ -> raise - (Ocsigen_config.Config_file_error + (Ocsigen_config.Config_file_error ("While parsing <"^tag^"> - String expected.")) @@ -215,7 +215,7 @@ (* Splits the [host] field, first according to spaces (which encode disjunction), and then according to wildcards '*' ; we then transform the hosts-with-regexp - into a regepx that matches a potential host. + into a regepx that matches a potential host. The whole result is cached because user config files (for userconf) are read at each request. *) let parse_host_field = @@ -299,6 +299,8 @@ parse_server_aux ll | (Element ("logdir", [], p))::ll -> parse_server_aux ll + | (Element ("syslog", [], p))::ll -> + parse_server_aux ll | (Element ("ssl", [], p))::ll -> parse_server_aux ll | (Element ("user", [], p))::ll -> @@ -426,26 +428,29 @@ end; parse_server_aux ll | (Element ("host", atts, l))::ll -> - let rec parse_attrs ((name, - charset, - defaulthostname, - defaulthttpport, - defaulthttpsport) as r) = function + let rec parse_attrs ((name, + charset, + defaulthostname, + defaulthttpport, + defaulthttpsport, + ishttps) as r) = function | [] -> r | ("hostfilter", s)::suite -> (match name with - | None -> parse_attrs ((Some s), charset, - defaulthostname, - defaulthttpport, - defaulthttpsport) suite + | None -> parse_attrs ((Some s), charset, + defaulthostname, + defaulthttpport, + defaulthttpsport, + ishttps) suite | _ -> raise (Ocsigen_config.Config_file_error ("Duplicate attribute name in "))) | ("charset", s)::suite -> (match charset with - | None -> parse_attrs (name, Some s, - defaulthostname, - defaulthttpport, - defaulthttpsport) suite + | None -> parse_attrs (name, Some s, + defaulthostname, + defaulthttpport, + defaulthttpsport, + ishttps) suite | _ -> raise (Ocsigen_config.Config_file_error ("Duplicate attribute charset in "))) | ("defaulthostname", s)::suite -> @@ -455,7 +460,8 @@ parse_attrs (name, charset, (Some s), defaulthttpport, - defaulthttpsport) suite + defaulthttpsport, + ishttps) suite else raise (Ocsigen_config.Config_file_error ("Incorrect hostname " ^ s)) @@ -463,26 +469,38 @@ ("Duplicate attribute defaulthostname in "))) | ("defaulthttpport", s)::suite -> (match defaulthttpport with - | None -> parse_attrs (name, charset, - defaulthostname, - (Some s), - defaulthttpsport) suite + | None -> parse_attrs (name, charset, + defaulthostname, + (Some s), + defaulthttpsport, + ishttps) suite | _ -> raise (Ocsigen_config.Config_file_error ("Duplicate attribute defaulthttpport in "))) | ("defaulthttpsport", s)::suite -> (match defaulthttpsport with - | None -> parse_attrs (name, charset, - defaulthostname, - defaulthttpport, - Some s) suite + | None -> parse_attrs (name, charset, + defaulthostname, + defaulthttpport, + Some s, + ishttps) suite | _ -> raise (Ocsigen_config.Config_file_error ("Duplicate attribute defaulthttpsport in "))) + | ("defaultprotocol", s)::suite -> + (match ishttps with + | None -> parse_attrs (name, charset, + defaulthostname, + defaulthttpport, + defaulthttpsport, + Some s) suite + | _ -> raise (Ocsigen_config.Config_file_error + ("Duplicate attribute defaultprotocol in "))) | (s, _)::_ -> raise (Ocsigen_config.Config_file_error ("Wrong attribute for : "^s)) in - let host, charset, defaulthostname, defaulthttpport,defaulthttpsport = - parse_attrs (None, None, None, None, None) atts + let host, charset, defaulthostname, defaulthttpport, + defaulthttpsport, defaultprotocol = + parse_attrs (None, None, None, None, None, None) atts in let host = parse_host_field host in let charset = @@ -510,6 +528,7 @@ Ocsigen_extensions.default_hostname = defaulthostname; default_httpport = defaulthttpport; default_httpsport = defaulthttpsport; + default_protocol_is_https = defaultprotocol = Some "https"; mime_assoc = Ocsigen_charset_mime.default_mime_assoc (); charset_assoc = Ocsigen_charset_mime.empty_charset_assoc ~default:charset (); @@ -599,6 +618,30 @@ int_of_string "port" (get r 2) | None -> All, int_of_string "port" s +let parse_facility = function + | "auth" -> `Auth + | "authpriv" -> `Authpriv + | "console" -> `Console + | "cron" -> `Cron + | "daemon" -> `Daemon + | "ftp" -> `FTP + | "kernel" -> `Kernel + | "lpr" -> `LPR + | "local0" -> `Local0 + | "local1" -> `Local1 + | "local2" -> `Local2 + | "local3" -> `Local3 + | "local4" -> `Local4 + | "local5" -> `Local5 + | "local6" -> `Local6 + | "local7" -> `Local7 + | "mail" -> `Mail + | "ntp" -> `NTP + | "news" -> `News + | "security" -> `Security + | "syslog" -> `Syslog + | "uucp" -> `UUCP + | "user" -> `User;; (* First parsing of config file *) let extract_info c = @@ -625,6 +668,10 @@ | (Element ("logdir" as st, [], p))::ll -> set_logdir (parse_string_tag st p); aux user group ssl ports sslports minthreads maxthreads ll + | (Element ("syslog" as st, [], p))::ll -> + let str = String.lowercase (parse_string_tag st p) in + set_syslog_facility (Some (parse_facility str)); + aux user group ssl ports sslports minthreads maxthreads ll | (Element ("port" as st, atts, p))::ll -> (match atts with [] @@ -699,7 +746,7 @@ ((user, group), si, (mint, maxt)) let parse_config ?file () = - let file = + let file = match file with | None -> Ocsigen_config.get_config_file () | Some f -> f diff -Nru ocsigenserver-2.2.0/src/server/ocsigen_range.ml ocsigenserver-2.4.0/src/server/ocsigen_range.ml --- ocsigenserver-2.2.0/src/server/ocsigen_range.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/server/ocsigen_range.ml 2014-04-16 16:01:15.000000000 +0000 @@ -44,16 +44,17 @@ then Ocsigen_stream.empty None else (match step with - | Ocsigen_stream.Finished _ -> + | Ocsigen_stream.Finished _ -> Lwt.fail Ocsigen_stream.Stream_too_small | Ocsigen_stream.Cont (c, f) -> Lwt.return (c, f)) >>= fun (buf, nextstream) -> let buflen = String.length buf in let buflen64 = Int64.of_int buflen in if (Int64.compare buflen64 num) <= 0 - then - Ocsigen_stream.next nextstream >>= fun next -> - Ocsigen_stream.cont buf (aux next (Int64.sub num buflen64)) + then + Ocsigen_stream.cont buf (fun () -> + Ocsigen_stream.next nextstream >>= fun next -> + aux next (Int64.sub num buflen64) ()) else Ocsigen_stream.cont (String.sub buf 0 (Int64.to_int num)) (fun () -> Ocsigen_stream.empty None) @@ -63,12 +64,12 @@ skipfun stream beg >>= fun new_s -> Lwt.return (match endopt with - | None -> + | None -> Ocsigen_stream.make ~finalize: (fun status -> Ocsigen_stream.finalize stream status) (fun () -> Lwt.return new_s) - | Some endc -> + | Some endc -> Ocsigen_stream.make ~finalize: (fun status -> Ocsigen_stream.finalize stream status) @@ -93,14 +94,14 @@ else begin let res = {res with Ocsigen_http_frame.res_headers = - Http_headers.replace + Http_headers.replace Http_headers.accept_ranges "bytes" res.Ocsigen_http_frame.res_headers; } in match change_range (Lazy.force ri.Ocsigen_extensions.ri_range) with | None -> Lwt.return res - | Some (_, _, Ocsigen_extensions.IR_ifmatch etag) + | Some (_, _, Ocsigen_extensions.IR_ifmatch etag) when (match res.Ocsigen_http_frame.res_etag with | None -> true | Some resetag -> String.compare etag resetag <> 0) -> @@ -118,7 +119,7 @@ (if Int64.compare cl beg <= 0 then Lwt.fail Range_416 else Lwt.return ()) >>= fun () -> - + let endc, length = match endopt with | None -> (Int64.sub cl 1L, Int64.sub cl beg) | Some e -> (e, Int64.add (Int64.sub e beg) 1L) @@ -128,25 +129,25 @@ res.Ocsigen_http_frame.res_stream in (* stream transform *) - let skipfun = + let skipfun = match skipfun with - | None -> + | None -> (fun stream beg -> - (Ocsigen_stream.next + (Ocsigen_stream.next (Ocsigen_stream.get stream) >>= fun s -> Ocsigen_stream.skip s beg)) | Some f -> f in - select_range + select_range length beg endopt skipfun resstream >>= fun new_s -> - Lwt.return + Lwt.return {res with Ocsigen_http_frame.res_stream = (new_s, None); Ocsigen_http_frame.res_code = 206; Ocsigen_http_frame.res_headers = - Http_headers.replace + Http_headers.replace Http_headers.content_range ("bytes "^Int64.to_string beg^"-"^ Int64.to_string endc^"/"^ @@ -163,7 +164,7 @@ {dr with Ocsigen_http_frame.res_code = 416; Ocsigen_http_frame.res_headers = - Http_headers.replace + Http_headers.replace Http_headers.content_range ("bytes */"^Int64.to_string cl) res.Ocsigen_http_frame.res_headers; @@ -180,7 +181,7 @@ Http_headers.range in - let decode_int index d e = + let decode_int index d e = let a = Int64.of_string d in let b = Int64.of_string e in assert (Int64.compare index a < 0); @@ -196,7 +197,7 @@ let l = String.split ',' b in let rec f index = function | [] -> [], None - | [a] -> + | [a] -> let d, e = String.sep '-' a in if e = "" then [], Some (Int64.of_string d) @@ -210,8 +211,8 @@ f (-1L) l in - let ifrange = - try + let ifrange = + try let ifrangeheader = Ocsigen_http_frame.Http_header.get_headers_value http_frame.Ocsigen_http_frame.frame_header Http_headers.if_range diff -Nru ocsigenserver-2.2.0/src/server/ocsigen_server.ml ocsigenserver-2.4.0/src/server/ocsigen_server.ml --- ocsigenserver-2.2.0/src/server/ocsigen_server.ml 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/src/server/ocsigen_server.ml 2014-04-16 16:01:15.000000000 +0000 @@ -1,7 +1,7 @@ (* Ocsigen * http://www.ocsigen.org * Copyright (C) 2005 - * Vincent Balat, Denis Berthod, Nataliya Guts, Jérôme Vouillon + * Vincent Balat, Denis Berthod, Nataliya Guts, Jérôme Vouillon * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -31,7 +31,6 @@ open Ocsigen_cookies open Lazy - exception Ocsigen_unsupported_media exception Ssl_Exception exception Ocsigen_upload_forbidden @@ -79,17 +78,17 @@ corresponds to the net.ipv6.bindv6only=0 behaviour on Linux, but is portable and should work with net.ipv6.bindv6only=1 as well. *) - let ipv6_socket = - try [make_ipv6_socket Unix.inet6_addr_any port] - with Unix.Unix_error - ((Unix.EAFNOSUPPORT | Unix.EPROTONOSUPPORT), - _, _) -> [] - in - (make_ipv4_socket Unix.inet_addr_any port)::ipv6_socket + let ipv6_socket = + try [make_ipv6_socket Unix.inet6_addr_any port] + with Unix.Unix_error + ((Unix.EAFNOSUPPORT | Unix.EPROTONOSUPPORT), + _, _) -> [] + in + (make_ipv4_socket Unix.inet_addr_any port)::ipv6_socket | IPv4 addr -> - [make_ipv4_socket addr port] + [make_ipv4_socket addr port] | IPv6 addr -> - [make_ipv6_socket addr port] + [make_ipv6_socket addr port] let sslctx = Ocsigen_http_client.sslcontext @@ -112,7 +111,8 @@ type to_write = No_File of string * Buffer.t - | A_File of (string * string * string * Unix.file_descr * (string * string option) option) + | A_File of (string * string * string * Unix.file_descr + * ((string * string) * (string * string) list) option) let counter = let c = ref (Random.int 1000000) in fun () -> c := !c + 1 ; !c @@ -127,8 +127,6 @@ "While talking to " ^ ip ^ ": " ^ s) -let r_content_type = Netstring_pcre.regexp "([^ ]*)" - let http_url_syntax = Hashtbl.find Neturl.common_url_syntax "http" let rec find_post_params http_frame ct filenames = @@ -176,14 +174,7 @@ let content_type = try let ct = List.assoc "content-type" hs in - let content_type = - let (_, res) = Netstring_pcre.search_forward r_content_type ct 0 in - Netstring_pcre.matched_group res 1 ct - in - let charset = try - Some (find_field "charset" ct) - with _ -> None - in Some (content_type, charset) + Ocsigen_headers.parse_content_type (Some ct) with _ -> None in let cd = List.assoc "content-disposition" hs in @@ -222,7 +213,7 @@ | No_File (p_name, to_buf) -> return (params := !params @ [(p_name, Buffer.contents to_buf)]) - (* à la fin ? *) + (* a la fin ? *) | A_File (p_name,fname,oname,wh, content_type) -> (* Ocsigen_messages.debug "closing file"; *) files := @@ -243,11 +234,47 @@ Ocsigen_stream.consume body_gen >>= fun () -> Lwt.return (!params, !files) +let wrap_stream f x frame_content = + Ocsigen_stream.make ~finalize:(fun outcome -> + match frame_content with + | Some stream -> + Ocsigen_stream.finalize stream outcome + | None -> + Lwt.return () + ) + (fun () -> + f x >>= fun () -> + match frame_content with + | Some stream -> + Ocsigen_stream.next (Ocsigen_stream.get stream) + | None -> + Ocsigen_stream.empty None + ) +let handle_100_continue slot frame = + { frame with + frame_content = Some (wrap_stream send_100_continue slot + frame.frame_content) + } + +let handle_expect slot frame = + let expect_list = Ocsigen_headers.get_expect frame in + let proto = Http_header.get_proto frame.frame_header in + List.fold_left (fun frame tok -> + match String.lowercase tok with + | "100-continue" -> + if proto = Http_header.HTTP11 then + handle_100_continue slot frame + else + frame + | _ -> + raise (Ocsigen_http_error (Ocsigen_cookies.empty_cookieset, 417)) + ) frame expect_list (* reading the request *) let get_request_infos - meth clientproto url http_frame filenames sockaddr port receiver = + meth clientproto url http_frame filenames sockaddr port receiver + sender_slot = Lwt.catch (fun () -> @@ -329,6 +356,8 @@ let post_params0 = match meth with | Http_header.GET + | Http_header.DELETE + | Http_header.PUT | Http_header.HEAD -> None | Http_header.POST | Http_header.OPTIONS -> @@ -380,7 +409,7 @@ ri_files = files; ri_remote_inet_addr = client_inet_addr; ri_remote_ip = ipstring; - ri_remote_ip_parsed = lazy (fst (Ip_address.parse ipstring)); + ri_remote_ip_parsed = lazy (Ipaddr.of_string_exn ipstring); ri_remote_port = port_of_sockaddr sockaddr; ri_forward_ip = []; ri_server_port = port; @@ -402,7 +431,7 @@ ri_accept_charset = accept_charset; ri_accept_encoding = accept_encoding; ri_accept_language = accept_language; - ri_http_frame = http_frame; + ri_http_frame = handle_expect sender_slot http_frame; ri_request_cache = Polytables.create (); ri_client = Ocsigen_extensions.client_of_connection receiver; ri_range = lazy (Ocsigen_range.get_range http_frame); @@ -640,7 +669,9 @@ if meth <> Http_header.GET && meth <> Http_header.POST && meth <> Http_header.HEAD && - meth <> Http_header.OPTIONS + meth <> Http_header.OPTIONS && + meth <> Http_header.DELETE && + meth <> Http_header.PUT then begin (* VVV Warning: This must be done once and only once. Put this somewhere else to ensure that? @@ -661,8 +692,8 @@ Lwt.try_bind (fun () -> get_request_infos - meth clientproto url request filenames sockaddr - port receiver) + meth clientproto url request filenames sockaddr + port receiver sender_slot) (fun ri -> (* *** Now we generate the page and send it *) (* Log *) @@ -689,7 +720,7 @@ ri.ri_remote_ip ri.ri_user_agent ri.ri_url_string); - let send_aux = + let send_aux = send sender_slot ~clientproto ~head ~sender:Ocsigen_http_com.default_sender in @@ -798,22 +829,22 @@ let try_bind' f g h = Lwt.try_bind f h g -let add_to_receivers_waiting_for_pipeline, +let add_to_receivers_waiting_for_pipeline, remove_from_receivers_waiting_for_pipeline, iter_receivers_waiting_for_pipeline = let l = Clist.create () in - ((fun r -> + ((fun r -> let node = Clist.make r in Clist.insert l node; node), Clist.remove, - (fun f -> + (fun f -> Clist.fold_left (fun t v -> (*VVV reread this. Is yield here ok? *) t >>= Lwt_unix.yield >>= fun () -> f v) - (Lwt.return ()) + (Lwt.return ()) l)) let handle_connection port in_ch sockaddr = @@ -908,7 +939,7 @@ | Some pos -> remove_from_receivers_waiting_for_pipeline pos | None -> ()); let meth, url = - match + match Http_header.get_firstline request.Ocsigen_http_frame.frame_header with | Http_header.Query a -> a @@ -924,11 +955,11 @@ if not !shutdown && get_keepalive request.Ocsigen_http_frame.frame_header then - (* We put the receiver in the set of receiver waiting for + (* We put the receiver in the set of receiver waiting for pipeline in order to be able to shutdown the connections if the server is shutting down. *) - handle_request + handle_request ~receiver_pos:(add_to_receivers_waiting_for_pipeline receiver) () else (* No keep-alive => no pipeline *) (* We wait for the query to be entirely read and for @@ -958,7 +989,7 @@ wait_connection use_ssl port socket in try_bind' - (fun () -> + (fun () -> (* if too much connections, we wait for a signal before accepting again *) let max = get_max_number_of_connections () in @@ -971,7 +1002,7 @@ (get_max_number_of_connections ()))); wait_fewer_connected max end) >>= fun () -> - (* We do several accept(), as explained in + (* We do several accept(), as explained in "Accept()able strategies ..." by Tim Brecht & al. *) Lwt_unix.accept_n socket 50) handle_exn @@ -981,7 +1012,7 @@ (fun () -> "received "^string_of_int number_of_accepts^" accepts" ); incr_connected number_of_accepts; if e = None then ignore (wait_connection use_ssl port socket); - + let handle_one (s, sockaddr) = Ocsigen_messages.debug2 "\n__________________NEW CONNECTION__________________________"; @@ -1010,7 +1041,7 @@ | e -> Lwt.fail e) >>= decr_connected in - + Lwt_util.iter handle_one l >>= fun () -> match e with | Some e -> handle_exn e @@ -1082,9 +1113,9 @@ let reload_conf s = try Ocsigen_extensions.start_initialisation (); - + parse_server true s; - + Ocsigen_extensions.end_initialisation (); with e -> Ocsigen_extensions.end_initialisation (); @@ -1106,18 +1137,18 @@ let shutdown_server s l = - try + try let timeout = match l with | [] -> Ocsigen_config.get_shutdown_timeout () | ["notimeout"] -> None - | [t] -> + | [t] -> Some (float_of_string t) | _ -> failwith "syntax error in command" in Ocsigen_messages.warning "Shutting down"; - List.iter + List.iter (fun s -> Lwt_unix.abort s Socket_closed) !sockets; - List.iter + List.iter (fun s -> Lwt_unix.abort s Socket_closed) !sslsockets; sockets := []; sslsockets := []; @@ -1333,6 +1364,11 @@ >>= f in ignore (f ()); + Lwt.async_exception_hook := (fun e -> + (* replace the default "exit 2" behaviour *) + Ocsigen_messages.errlog ("Uncaught Exception: "^ Printexc.to_string e) + ); + Lwt.wakeup wait_end_init_awakener (); Ocsigen_messages.warning "Ocsigen has been launched (initialisations ok)"; @@ -1365,7 +1401,7 @@ let f = Unix.openfile p - [Unix.O_WRONLY; Unix.O_CREAT; Unix.O_APPEND] 0o640 in + [Unix.O_WRONLY; Unix.O_CREAT; Unix.O_TRUNC] 0o640 in ignore (Unix.write f spid 0 len); Unix.close f in diff -Nru ocsigenserver-2.2.0/VERSION ocsigenserver-2.4.0/VERSION --- ocsigenserver-2.2.0/VERSION 2012-12-07 15:17:09.000000000 +0000 +++ ocsigenserver-2.4.0/VERSION 2014-04-16 16:01:15.000000000 +0000 @@ -1 +1 @@ -2.2.0 +2.4.0