diff --git a/Makefile b/Makefile index 046b547b8b..b256365520 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ ASYNC ?= $(shell if ocamlfind query async >/dev/null 2>&1; then echo --enable-as JS ?= $(shell if ocamlfind query js_of_ocaml >/dev/null 2>&1; then echo --enable-js; fi) #NETTESTS ?= --enable-tests --enable-nettests +setup.ml: _oasis + oasis setup -setup-update none + setup.bin: setup.ml ocamlopt.opt -o $@ $< 2>/dev/null || ocamlopt -o $@ $< 2>/dev/null || ocamlc -o $@ $< rm -f setup.cmx setup.cmi setup.o setup.cmo diff --git a/_oasis b/_oasis index df57cb79f7..1ae6189c4a 100644 --- a/_oasis +++ b/_oasis @@ -18,6 +18,7 @@ Homepage: https://github.com/mirage/ocaml-cohttp License: ISC Plugins: META (0.3) BuildTools: ocamlbuild +FilesAB: lib/conf.ml.ab Library cohttp Path: lib @@ -26,6 +27,7 @@ Library cohttp Modules: S, Code, Header, Cookie, Request, Response, Transfer, Accept, Accept_parser, Accept_lexer, Accept_types, Auth, Header_io, Transfer_io, Connection, Body, String_io + InternalModules: Conf BuildDepends: re.emacs, stringext, uri (>= 1.5.0), uri.services, fieldslib (>= 109.20.00), fieldslib.syntax, sexplib (>= 109.53.00), sexplib.syntax, diff --git a/_tags b/_tags index 63f15d2706..ac1d41b36e 100644 --- a/_tags +++ b/_tags @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 3a1126cc930825def71880e9cfd739d1) +# DO NOT EDIT (digest: 2a142d4ea34f0b943dc2f4ea64492657) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process @@ -33,6 +33,7 @@ true: annot, bin_annot "lib/connection.cmx": for-pack(Cohttp) "lib/body.cmx": for-pack(Cohttp) "lib/string_io.cmx": for-pack(Cohttp) +"lib/conf.cmx": for-pack(Cohttp) : pkg_base64 : pkg_bytes : pkg_fieldslib diff --git a/lib/cohttp.mlpack b/lib/cohttp.mlpack index e8be3f730e..be8e20b32e 100644 --- a/lib/cohttp.mlpack +++ b/lib/cohttp.mlpack @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 67e2359b5db1a02e2b140598730d1456) +# DO NOT EDIT (digest: c155920e0546031ef19fb415d7852c55) S Code Header @@ -17,4 +17,5 @@ Transfer_io Connection Body String_io +Conf # OASIS_STOP diff --git a/lib/conf.ml b/lib/conf.ml new file mode 100644 index 0000000000..e1ad84b2d7 --- /dev/null +++ b/lib/conf.ml @@ -0,0 +1,18 @@ +(* -*-tuareg-*- + * Copyright (c) 2015 Christophe Troestler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + *) + +let user_agent = "ocaml-cohttp/0.15.0" diff --git a/lib/conf.ml.ab b/lib/conf.ml.ab new file mode 100644 index 0000000000..ac9a318f5c --- /dev/null +++ b/lib/conf.ml.ab @@ -0,0 +1,18 @@ +(* -*-tuareg-*- + * Copyright (c) 2015 Christophe Troestler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + *) + +let user_agent = "ocaml-cohttp/${pkg_version}" diff --git a/lib/conf.mli b/lib/conf.mli new file mode 100644 index 0000000000..25f904ee34 --- /dev/null +++ b/lib/conf.mli @@ -0,0 +1,19 @@ +(* + * Copyright (c) 2015 Christophe Troestler + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + *) + +val user_agent : string +(** User-Agent, including the version of this library. *) diff --git a/lib/header.ml b/lib/header.ml index 6f84439d79..db53d37822 100644 --- a/lib/header.ml +++ b/lib/header.ml @@ -32,7 +32,7 @@ end module StringMap = Map.Make(LString) type t = string list StringMap.t -let user_agent = "ocaml-cohttp" (* TODO: include version from build system *) +let user_agent = Conf.user_agent let headers_with_list_values = List.map LString.of_string [ "accept";"accept-charset";"accept-encoding";"accept-language"; diff --git a/lib/header.mli b/lib/header.mli index 02f2a19eec..0564a91ca1 100644 --- a/lib/header.mli +++ b/lib/header.mli @@ -77,6 +77,10 @@ val add_authorization_req : t -> Auth.challenge -> t val is_form : t -> bool val user_agent : string +(** The User-Agent header used by this library, including the version + of cohttp. *) val prepend_user_agent : t -> string -> t +(** Prepend [user_agent] to the product token already declared in the + "User-Agent" field (if any). *) val connection : t -> [`Keep_alive | `Close | `Unknown of string] option diff --git a/setup.ml b/setup.ml index 900f9a784d..b351eb616c 100644 --- a/setup.ml +++ b/setup.ml @@ -1,7 +1,7 @@ (* setup.ml generated for the first time by OASIS v0.4.5 *) (* OASIS_START *) -(* DO NOT EDIT (digest: 4499515f5fd925c4fa540b77b9b4cdc2) *) +(* DO NOT EDIT (digest: 1f8c95306ece78483a9ad5ebf3e52b6b) *) (* Regenerated by OASIS v0.4.5 Visit http://oasis.forge.ocamlcore.org for more information and @@ -7045,7 +7045,7 @@ let setup_t = pre_command = [(OASISExpr.EBool true, None)]; post_command = [(OASISExpr.EBool true, None)] }; - files_ab = []; + files_ab = ["lib/conf.ml.ab"]; sections = [ Library @@ -7112,7 +7112,7 @@ let setup_t = "String_io" ]; lib_pack = true; - lib_internal_modules = []; + lib_internal_modules = ["Conf"]; lib_findlib_parent = None; lib_findlib_name = Some "cohttp"; lib_findlib_containers = [] @@ -8396,7 +8396,7 @@ let setup_t = }; oasis_fn = Some "_oasis"; oasis_version = "0.4.5"; - oasis_digest = Some "\"-\018¬(NO7ß\139H÷«·\132ô"; + oasis_digest = Some "^~O\192\167\170\194\147\006\141\242Z\215p\239\131"; oasis_exec = None; oasis_setup_args = []; setup_update = false