package tiny_httpd

  1. Overview
  2. Docs
Minimal HTTP server using threads

Install

Dune Dependency

Authors

Maintainers

Sources

tiny_httpd-0.18.tbz
sha256=ef806444b2f9e53d10976b9124902560d0855124433537080e6d0bec48d202e5
sha512=539530eb9e511b6ed4d69bb083f421d5f51b183c347c116a52f24210f30b1c9b14a029e2b82d6e0d698c74ab75ba5c307a1976711558a1419df287335b2a8f51

doc/src/tiny_httpd.multipart-form-data/content_disposition.ml.html

Source file content_disposition.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
open Utils_

type t = { kind: string; name: string option; filename: string option }

(** Simple display *)
let to_string (self : t) =
  let stropt = function
    | None -> "None"
    | Some s -> spf "%S" s
  in
  spf "{kind=%S; name=%s; filename=%s}" self.kind (stropt self.name)
    (stropt self.filename)

let parse (hs : Tiny_httpd.Headers.t) : t option =
  match Tiny_httpd.Headers.get "content-disposition" hs with
  | None -> None
  | Some s ->
    (match String.split_on_char ';' s with
    | [] ->
      failwith (Printf.sprintf "multipart: invalid content-disposition %S" s)
    | kind :: tl ->
      let name = ref None in
      let filename = ref None in
      List.iter
        (fun s ->
          match Utils_.split1_on ~c:'=' @@ String.trim s with
          | Some ("name", v) -> name := Some (Utils_.remove_quotes v)
          | Some ("filename", v) -> filename := Some (Utils_.remove_quotes v)
          | _ -> ())
        tl;
      Some { kind; name = !name; filename = !filename })
OCaml

Innovation. Community. Security.