package cohttp
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
An OCaml library for HTTP clients and servers
Install
dune-project
Dependency
Authors
Maintainers
Sources
cohttp-6.1.1.tbz
sha256=6b420c56203b3a0b515964f036bcea0fb9a362876b5791cd7ff50e12366c489c
sha512=839ff6156658ca6d7922e6eed63ebb84dd09c76107790477be55a1ffc4a3800bf49c435147a0ed628f147eaeccff9a8d34565e3787f32c15e187b6e8855f0b93
doc/src/cohttp/header.ml.html
Source file header.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98(*{{{ Copyright (c) 2012 Anil Madhavapeddy <anil@recoil.org> * Copyright (c) 2011-2012 Martin Jambon <martin@mjambon.com> * Copyright (c) 2010 Mika Illouz * * 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. * }}}*) include Http.Header let media_type_re = let re = Re.Emacs.re ~case:true "[ \t]*\\([^ \t;]+\\)" in Re.(compile (seq [ start; re ])) let get_first_match s = try let subs = Re.exec ~pos:0 media_type_re s in let start, stop = Re.Group.offset subs 1 in Some (String.sub s start (stop - start)) with Not_found -> None (* Grab "foo/bar" from " foo/bar ; charset=UTF-8" *) let get_media_type headers = match get headers "content-type" with | Some s -> get_first_match s | None -> None let get_acceptable_media_ranges headers = Accept.media_ranges (get_multi_concat ~list_value_only:true headers "accept") let get_acceptable_charsets headers = Accept.charsets (get_multi_concat ~list_value_only:true headers "accept-charset") let get_acceptable_encodings headers = Accept.encodings (get_multi_concat ~list_value_only:true headers "accept-encoding") let get_acceptable_languages headers = Accept.languages (get_multi_concat ~list_value_only:true headers "accept-language") let headers challenge = add headers "www-authenticate" (Auth.string_of_challenge challenge) let headers cred = add headers "authorization" (Auth.string_of_credential cred) let headers = match get headers "authorization" with | None -> None | Some v -> Some (Auth.credential_of_string v) let is_form headers = get_media_type headers = Some "application/x-www-form-urlencoded" let get_location headers = match get_location headers with | None -> None | Some u -> Some (Uri.of_string u) let get_links headers = List.rev (List.fold_left (fun list link_s -> List.rev_append (Link.of_string link_s) list) [] (get_multi headers "link")) let add_links headers links = add_multi headers "link" (List.map Link.to_string links) let user_agent = Printf.sprintf "ocaml-cohttp/%s" Conf.version let prepend_user_agent headers user_agent = let k = "user-agent" in match get headers k with | Some ua -> replace headers k (user_agent ^ " " ^ ua) | None -> add headers k user_agent open Sexplib0.Sexp_conv let sexp_of_t t = sexp_of_list (sexp_of_pair sexp_of_string sexp_of_string) (to_list t) let t_of_sexp s = of_list (list_of_sexp (pair_of_sexp string_of_sexp string_of_sexp) s) let pp_hum ppf h = Format.fprintf ppf "%s" (h |> sexp_of_t |> Sexplib0.Sexp.to_string_hum)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>